在datagrid SelectionChanged事件增加以下代码,如果当前选择的数量大于1,则把详细信息收缩,否则,当选定的时候在咱开。
private void dgList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (this.dgList.SelectedItems.Count > 1)
{
dgList.RowDetailsVisibilityMode = DataGridRowDetailsVisibilityMode.Collapsed;
}
else
dgList.RowDetailsVisibilityMode = DataGridRowDetailsVisibilityMode.VisibleWhenSelected;
}
{
if (this.dgList.SelectedItems.Count > 1)
{
dgList.RowDetailsVisibilityMode = DataGridRowDetailsVisibilityMode.Collapsed;
}
else
dgList.RowDetailsVisibilityMode = DataGridRowDetailsVisibilityMode.VisibleWhenSelected;
}