如何将属性访问XAML [英] How to access property into XAML
本文介绍了如何将属性访问XAML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是WPF的新手
提到我在课堂上有财产
I am a newbie in WPF
As mention I have property in class
public ObservableCollection<Company> GetCompany
{
get
{
return _collectionCompany;
}
}
如何在XAML中访问它?
我正在尝试这样:
How can I access it in XAML?
I am trying like this:
<DataGridComboBoxColumn Header="Company" ItemsSource="{StaticResource GetCompany}" Width="200"></DataGridComboBoxColumn>
但这会出错.
But it gives an error.
推荐答案
使其具有依赖项属性,然后可以将其与绑定语法一起使用.希望对您有帮助
-Raghu
Make it a dependency property and you can use it with binding syntax. Hope it helps
-Raghu
看看:
StaticResource标记扩展
[ ^ ]
看看在WPF中使用静态资源 [ http://stackoverflow.com/questions/896587/wpf-bind-collection-with-collection-to-a-listbox-with-groups [将WPF组合框绑定到自定义列表 [
然后是微软的这篇技术文章:
Windows Presentation Foundation数据绑定:第2部分 [
Take a look at:
StaticResource Markup Extension
[^]
Take a look at Using StaticResources in WPF[^]
Here is an example showing how to do what I think you want to accomplish:
http://stackoverflow.com/questions/896587/wpf-bind-collection-with-collection-to-a-listbox-with-groups[^]
Here is an even simpler answer:
Binding WPF ComboBox to a Custom List[^]
CollectionView supports the notions of a "CurrentItem" and and a "CurrentPosition"
And then there is this technical article from Microsoft:
Windows Presentation Foundation Data Binding: Part 2[^]
Regards
Espen Harlinn
查看此链接,它涉及到ItemsItem的使用:
http://stackoverflow.com/questions/1724180/problem-binding-datagridcomboboxcolumn-itemssource [ ^ ]
http://stackoverflow.com/questions/2890156/how-to-bind-collection- to-wpfdatagridcomboboxcolumn [^ ]
Check out this link, it involves the use ItemsSource :
http://stackoverflow.com/questions/1724180/problem-binding-datagridcomboboxcolumn-itemssource[^]
http://stackoverflow.com/questions/2890156/how-to-bind-collection-to-wpfdatagridcomboboxcolumn[^]
这篇关于如何将属性访问XAML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文