WPF DataGrid Hide RowDetails or Unselect Row

Posted by Nate Zaugg on Stack Overflow See other posts from Stack Overflow or by Nate Zaugg
Published on 2010-03-17T23:08:52Z Indexed on 2010/03/17 23:11 UTC
Read the original article Hit count: 1903

Filed under:
|

I have a DataGrid who's RowDetails is set to show when selected (RowDetailsVisibilityMode="VisibleWhenSelected"). Now I want to be able to get rid of it! I put a close button on the row details with this code:

private void Button_Click(object sender, RoutedEventArgs e) { e.Handled = true; Button button = sender as Button; DataGridRow row = button.FindAncestor();

row.DetailsVisibility = Visibility.Collapsed; }

That code gets me 90% there, but once the row details is collapsed for a given row it will not appear the next time that row is selected.

© Stack Overflow or respective owner

Related posts about wpfdatagrid

Related posts about wpf