c# - Bind with WindowsFormsHost -
i trying bind list of items tabcontrol. items like:
class scieditor { private scintilla editor = null; public system.windows.forms.control editor { { return editor; } } private string path = null; public string shortname { { return null == path ? "new script" : path.getfilenamewithoutextension(path); } } .... in main window, list called "allscripts". here's xaml:
<tabcontrol grid.row="0" grid.column="0" name="tabcontrol1"> <tabcontrol.itemtemplate> <datatemplate> <textblock> <textblock text="{binding shortname}"/> </textblock> </datatemplate> </tabcontrol.itemtemplate> <tabcontrol.contenttemplate> <datatemplate> <windowsformshost child="{binding editor}" /> </datatemplate> </tabcontrol.contenttemplate> </tabcontrol> the problem can't set "child" in windowsformshost because
a 'binding' cannot set on 'child' property of type 'windowsformshost'. 'binding' can set on dependencyproperty of dependencyobject.
how can set windowsformshost child?
edit: forgot mention, in main window constructor have:
tabcontrol1.itemssource = allscripts;
change content template to
<tabcontrol.contenttemplate> <datatemplate> <contentcontrol content="{binding editor}" /> </datatemplate> </tabcontrol.contenttemplate> and change editor property of code-behind to
public windowsformshost editor { { return new windowsformshost(){child=editor}; } }
Comments
Post a Comment