与WindowsFormsHost绑定
我正在尝试将项目列表绑定到TabControl。 这些项目看起来像:
class SciEditor { private Scintilla editor = null; public System.Windows.Forms.Control Editor { get { return editor; } } private string path = null; public string ShortName { get { return null == path ? "New Script" : Path.GetFileNameWithoutExtension(path); } } ....
在我的主窗口中,List被称为“allScripts”。 这是XAML:
问题是我无法在WindowsFormsHost中设置“Child”,因为
无法在“WindowsFormsHost”类型的“Child”属性上设置“绑定”。 ‘绑定’只能在DependencyObject的DependencyProperty上设置。
如何设置WindowsFormsHost子项?
编辑:忘了提,在主窗口构造函数我有:
tabControl1.ItemsSource = allScripts;
将您的内容模板更改为
并将代码隐藏的Editor
属性更改为
public WindowsFormsHost Editor { get { return new WindowsFormsHost(){Child=editor}; } }