Hi,
I am trying to Select the very first row in my DataGrid. I used a couple of techniques to achieve it. The following one works fine where I explicity specify the contents of a cell.
However I thought that following should work on the same lines but it doesn't.
The Grid is bound to an XML file with multiple Employee records and I noticed that in the latter approach , following property remains null.
Please guide how can I achieve Selection of first row of DataGrid without specifying cell content. Also could you tell why doesn't the latter approach work when it retrieves the Row alright from ChildrenOfType<GridViewRow> collection? Thanks.
Best Regards,
David
I am trying to Select the very first row in my DataGrid. I used a couple of techniques to achieve it. The following one works fine where I explicity specify the contents of a cell.
var row = PeopleDataGrid.ChildrenOfType<GridViewRow>().Where(r => r.ChildrenOfType<GridViewCell>().Where(c => c.Content.ToString() == "David").Any()).First(); | |
if (row != null) | |
{ | |
row.IsSelected = true; | |
} |
However I thought that following should work on the same lines but it doesn't.
var row = PeopleDataGrid.ChildrenOfType<GridViewRow>().First(); | |
if (row != null) | |
{ | |
row.IsSelected = true; | |
} |
The Grid is bound to an XML file with multiple Employee records and I noticed that in the latter approach , following property remains null.
((Telerik.Windows.Controls.GridView.DetailsProvider)row.DetailsProvider).DataContext |
Please guide how can I achieve Selection of first row of DataGrid without specifying cell content. Also could you tell why doesn't the latter approach work when it retrieves the Row alright from ChildrenOfType<GridViewRow> collection? Thanks.
Best Regards,
David