So I need the cell text content of the DataGrid cell clicked or doubleclicked. Reading numerous questions I can't seem to see how this task so extremely trivial in WinForms can be done in WPF..?
Asked
Active
Viewed 109 times
1 Answers
0
From this I found a solution that works at least with .NET 4.5.2 :
var element = dg.CurrentColumn == null ? null : dg.Columns[dg.CurrentColumn.DisplayIndex].GetCellContent(dg.SelectedItem);
var text = element.GetType() == typeof(TextBox) ? ((TextBox)element).Text : null;
Console.WriteLine(text);

bretddog
- 5,411
- 11
- 63
- 111