使用datagrid的选定行项填充文本框组合框和复选框 [英] Populate Textbox Combobox and Checkbox with selected row items of datagrid
问题描述
我正在学习MVVM..我的视图中有一个数据网格,还有一个文本框,组合框和复选框.现在我要做的是用datagrid的选定行填充文本框,combobox和checkbox.我已经使用dataservice用数据库中的记录填充了datagrid.因此,现在当我选择任何行时,上述控件必须显示我选择的项目.
请建议如何实现..或演示将是有益的. .
因此,在您的文本框,组合框或其他控件中,您可以在xaml中执行类似的操作.
让我以TextBox为例:
< 文本框 文本 =" / >
希望能帮助到你. =)
I m learning MVVM.. I have a datagrid in my View and a textbox,combobox,checkbox. Now what I want to do is to fill the textbox,combobox and checkbox with the selected row items of my datagrid.I have used dataservice to populate my datagrid with records from database. So now when i will select any row then the controls mentioned above must show the items which i selected.
Plz suggest how can i achieve it..or a demo will be helpfull
You have a proerty called SelectedItem, this property represent your Row (is your selected object).
So in your TextBox, combobox or another control you can do Something like this, in your xaml.
Let me take the TextBox for the example:
<textbox text="{Binding ElementName=<b>nameofyourDataGrid</b>, Path=SelectedItem.<b>PropertyNameOfYourClass</b>}" />
Hope it helps. =)
这篇关于使用datagrid的选定行项填充文本框组合框和复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!