简体   繁体   English

将控件值绑定到选定的datagrid值

[英]Binding a control value to selected datagrid value

in WPF XAML i am trying to bind a control value to a Data Grid cell value, so whenever the selected row changes , the control text value will change 在WPF XAML中我试图将控件值绑定到数据网格单元格值,因此每当所选行更改时,控件文本值将更改

i tried to do something like 我试着做点什么

<TextBlock Text="{Binding MyGrid.Row.cname}" />

You can simply use ElementBinding eg 您可以简单地使用ElementBinding例如

<DataGrid x:Name="grid" ItemsSource="..." />
<TextBlock Text="{Binding ElementName=grid, Path=SelectedItem.cname}" />

You can find some more information here . 您可以在此处找到更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM