防止数据网格中的排序重置行可见性属性

时间:2014-01-31 13:40:44

标签: wpf sorting datagrid visibility

有没有办法阻止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();
    }

1 个答案:

答案 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
}