对于C#,我正在通过Tutorial为MEF(Managed Extensibility Framework)工作,但由于这两个代码行无法获取实用程序工作,教程它们可以在界面的大局之下找到):在C#中设置组合框的ItemSource和DisplayMemberPath#
cbTransformationOptions.ItemsSource = _tranformationEngine.Transformers;
cbTransformationOptions.DisplayMemberPath = "Name";
提到cbTransformationOptions
是一个普通的组合框。该代码将无法编译,我发现了以下错误:
'System.Windows.Forms.ComboBox' does not contain a definition for 'ItemsSource'
and no extension method 'ItemsSource' accepting a first argument of type
'System.Windows.Forms.ComboBox' could be found (are you missing a using directive
or an assembly reference?)
'System.Windows.Forms.ComboBox' does not contain a definition for 'DisplayMemberPath'
and no extension method 'DisplayMemberPath' accepting a first argument of type
'System.Windows.Forms.ComboBox' could be found (are you missing a using directive
or an assembly reference?)
我想通了,直到如今,是,这两个声明都以某种方式连接到WPF/XAML(我发现在计算器上一些参考) - 但我对这个话题没有任何经验,所以这些答案根本没有帮助我。
如何让代码工作?
谢谢。我将代码复制到一个新的wpf项目中,并且它工作正常! – DIF 2012-01-27 09:46:37