3wi*_*wic 1 c# wpf xaml datagrid datarowview
我当前正在尝试获取 DataGrid 中选定行的内容。
问题是我实际上得到了一个 DataRowView 但我无法用它做任何事情......
我想访问 DataGrid 中所选行的所有字段。
这是可以帮助您的代码:
XAML:
<DataGrid SelectionUnit="FullRow" SelectedItem="{Binding SelectedZone, Mode=TwoWay}" AutoGenerateColumns="True" Margin="0,167,6,24" Name="existingCase" Width="780" >
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}">
<EventSetter Event="MouseDoubleClick" Handler="resultDataGrid_MouseDoubleClick"/>
</Style>
</DataGrid.RowStyle>
</DataGrid>
Run Code Online (Sandbox Code Playgroud)
CS :
private void resultDataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (sender != null)
{
SelectedZone = existingCase.SelectedItem;
// SelectedZone is declared as private object SelectedZone
MessageBox.Show(SelectedZone.GetType().ToString());
// Result to a System.Data.DataRowView
}
}
Run Code Online (Sandbox Code Playgroud)
感谢您的帮助
| 归档时间: |
|
| 查看次数: |
3588 次 |
| 最近记录: |