如何从主xaml文件中访问UserControl中定义的DataGrid的ItemsSource属性? [英] How to access ItemsSource property of a DataGrid defined in UserControl from main xaml file?
本文介绍了如何从主xaml文件中访问UserControl中定义的DataGrid的ItemsSource属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在UserControl中声明了一个DataGrid。
I have declared a DataGrid in UserControl.
现在我已经将UserControl包含在我的主要xaml文件中。我试图从main.xaml设置DataGrid的ItemsSource属性;但是我收到一个错误属性ItemsSource不存在于命名空间。
Now I have included the UserControl in my main xaml file. I am trying to set the ItemsSource property of DataGrid from main.xaml; but I am getting an error "The property ItemsSource doesnot exist in the namespace".
我可以设置其他属性,如Background,Foreground等。
I am able to set the other properties like Background,Foreground, etc.
我的UserControl具有以下功能:
My UserControl has this :
<wpfkit:DataGrid Name="DataGrid1"
AutoGenerateColumns="True"
Width="Auto">
</wpfkit:DataGrid>
在main.xaml中:
In main.xaml :
<usercontrol:MultiStepProcessGrid ItemsSource="{Binding GridData}" ></usercontrol:MultiStepProcessGrid>
The above line is giving an error stating that ItemsSource doesnot exist in namespace.
So I wanted to know whether its possible to set the ItemsSource from main.xaml or not!!
请帮助我这个!
推荐答案
尝试这个
<wpfkit:DataGrid Name="DataGrid1"
ItemSource="{Binding}"
AutoGenerateColumns="True"
Width="Auto">
</wpfkit:DataGrid>
和
<usercontrol:MultiStepProcessGrid DataContext="{Binding GridData}" ></usercontrol:MultiStepProcessGrid>
这篇关于如何从主xaml文件中访问UserControl中定义的DataGrid的ItemsSource属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文