How to access the Rows collection?

3 posts, 0 answers
  1. Ristogod
    Ristogod avatar
    63 posts
    Member since:
    Aug 2008

    Posted 18 Oct 2010 Link to this post

    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. Ristogod
    Ristogod avatar
    63 posts
    Member since:
    Aug 2008

    Posted 18 Oct 2010 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Ristogod
    Ristogod avatar
    63 posts
    Member since:
    Aug 2008

    Posted 18 Oct 2010 Link to this post

    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();
    }
Back to Top