Alex Rivera | Logout

WPF DataGrid Hide RowDetails or Unselect Row

Asked 2010-03-17T23:08:52.363
12

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<DataGridRow>();

   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.

Edit
Report

1 Answer

1

try adding row.DetailsVisibility = Visibility.Visible; on the RowDetailsVisibilityChanged event.

answered 2010-04-22T17:07:14.250

Your Answer