有没有办法阻止DataGrid排序重置行可见性?
我尝试在“排序”事件中重新设置可见性而没有运气。 行似乎具有正确的可见性,但是当GUI绘制时,所有行都可见。
XAML:
<DataGrid x:Name="ErrorsList" Style="{StaticResource MyDataGrid}" Visibility="Hidden" CanUserResizeColumns="True" CanUserReorderColumns="True" ClipboardCopyMode="ExcludeHeader" VerticalAlignment="Stretch" Sorting="ErrorsList_OnSort">
CS:
private void ErrorsList_OnSort(object sender, System.Windows.Controls.DataGridSortingEventArgs e)
{
// no effect whatsoever
ChangeErrorsListRowsVisibility();
}
答案 0 :(得分:1)
嗯......这对我有用。
private void ErrorsList_OnSort(object sender, System.Windows.Controls.DataGridSortingEventArgs e)
{
ErrorsList.LoadingRow += ErrorsList_LoadingRow;
}
和...
void ErrorsList_LoadingRow(object sender, DataGridRowEventArgs e)
{
// Here I handled the visibility for each row
}