datagrid wpf 获取选中_c# WPF DataGrid 获取选中单元格信息

private void Dg_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)

{

Console.WriteLine("start");

foreach (DataGridCellInfo info in dg.SelectedCells)

{

FrameworkElement element = info.Column.GetCellContent(info.Item);

string str = ((TextBlock)info.Column.GetCellContent(info.Item)).Text;

Console.WriteLine(str);

}

}

private void Button_Click(object sender, RoutedEventArgs e)

{

DataGridCellInfo info = new DataGridCellInfo(dg.Items[], dg.Columns[]);

Console.WriteLine("start");

FrameworkElement element = info.Column.GetCellContent(info.Item);

string str = ((TextBlock)info.Column.GetCellContent(info.Item)).Text;

Console.WriteLine(str);

}

private void Button_Click(object sender, RoutedEventArgs e)

{

<

你可能感兴趣的:(datagrid,wpf,获取选中)