C# 在C中设置ComboBox的ItemSource和DisplayMemberPath#
我正在通过for MEF()for C#工作,但无法让示例项目wo工作,因为这两行代码(在链接教程中,它们可以在界面的大图下找到): 提到的C# 在C中设置ComboBox的ItemSource和DisplayMemberPath#,c#,wpf,combobox,C#,Wpf,Combobox,我正在通过for MEF()for C#工作,但无法让示例项目wo工作,因为这两行代码(在链接教程中,它们可以在界面的大图下找到): 提到的cbTransformationOptions是一个普通的组合框。代码无法编译,我遇到以下错误: 'System.Windows.Forms.ComboBox' does not contain a definition for 'ItemsSource' and no extension method 'ItemsSource' accepting a
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有某种联系(我在StackOverflow上找到了一些参考资料)——但我在这方面没有任何经验,所以这些答案对我毫无帮助
如何使代码正常工作?System.Windows.Forms是创建wpf项目所需的错误命名空间。本教程描述的是wpf项目,而您似乎正在尝试针对Windows Forms项目编译代码 WPF是Windows窗体的一种替代表示技术,其本身就是一个巨大的主题。如果您希望构建WPF项目,我建议您购买一本关于WPF的书
我不知道您在.NET方面的经验有多丰富,但C#2010中的专业WPF提供了极好的覆盖范围。谢谢。我将代码复制到一个新的wpf项目中,它成功了!
'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?)