I'm using the RowDetailsTemplate
in one of my DataGrids
. This works fine so far, but looks really odd when the user wants to select multiple rows for specific operations.
Is there a simple way to display the RowDetailsTemplate
only if exactly only one row is selected?
I'd love to solve this with pure XAML. Otherwise I'd do it with code behind:
private void DataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
DataGrid temp = sender as DataGrid;
if (temp.SelectedItems.Count == 1)
{
temp.RowDetailsVisibilityMode = DataGridRowDetailsVisibilityMode.VisibleWhenSelected;
}
else
{
temp.RowDetailsVisibilityMode = DataGridRowDetailsVisibilityMode.Collapsed;
}
}