Datagrid current Row/Value
This seems like a simple operation, but the solution has so far eluded me. I have a datagrid (I'm working in WPF) that is displaying data properly. I have some code in the previewkeydown event that I'd like to give me the value of the first cell in the grid that is currently selected. The following code works OK:
public static class DataGridHelper
{
public static DataGridCell GetCell(DataGridCellInfo dataGridCellInfo)
{
var cellContent = dataGridCellInfo.Column.GetCellContent(dataGridCellInfo.Item);
return (DataGridCell)cellContent.Parent;
}
}
I display the cell content in a textbox using:
DataGridCell cell = DataGridHelper.GetCell(MyDataGrid.SelectedCells[0]);
txtMisc.Text = cell.ToString();
This is what displays:
System.Windows.Controls.DataGridCell: 1245
I only need the 1245
Is there a way to remove everything except the 1245?