This is a migrated thread and some comments may be shown as answers.

How to access the Rows collection?

2 Answers 80 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ristogod
Top achievements
Rank 2
Ristogod asked on 18 Oct 2010, 05:20 PM
I am trying to implement the SelectionChanged event on the RadGridView. In that event, I want to collapse every row in the GridView except that one row that happens to be selected. However, I can't seem to figure out how to find the rows themselves to set the IsExpanded property to true or false. The items collection is available, but it only gives me access to the bound collection and not the GridViewRow items. How do I get the rows collection?

2 Answers, 1 is accepted

Sort by
0
Ristogod
Top achievements
Rank 2
answered on 18 Oct 2010, 08:09 PM
Nevermind. I stopped using the HeirarchicalChildTemplate and instead started using the RowDetailTemplate. By doing that I was able to use the RowDetailsVisibilityMode value of VisibleWhenSelected to get the behavior I wanted.

So I am still able to show my data Heirarchically by using a RadGridView in the RowDetailTemplate. The only issue I have now is when I select a row in the nested RadGridView, and it hasn't yet been shown, the binding doesn't work for SelectedItem on that nested RadGridView.
0
Ristogod
Top achievements
Rank 2
answered on 18 Oct 2010, 08:19 PM
I figured out how to get the binding to work for the nested RadGridView's SelectedItem property.

private void RadGridView_Loaded(object sender, RoutedEventArgs e)
{
    RadGridView gridView = sender as RadGridView;
 
    BindingExpression selectedItemBinding =
        gridView.GetBindingExpression(RadGridView.SelectedItemProperty);
 
    selectedItemBinding.UpdateTarget();
}
Tags
GridView
Asked by
Ristogod
Top achievements
Rank 2
Answers by
Ristogod
Top achievements
Rank 2
Share this question
or