检查WPF DataGrid中的SelectAll过滤记录

时间:2017-03-13 10:25:57

标签: c# wpf checkbox filter datagrid

如何在不使用可见行的情况下检查CheckAllBox事件过滤的所有记录? (现在只检查屏幕上可见的那些)。 这是背后的代码:

    private void CheckAllBox_OnClick(object sender, RoutedEventArgs e){

        var grid = itemsGrid;
        VisibleRows = new List<string>();
        if (grid == null)
            return;
        //Getting the visible rows in dataGrid after filter
        foreach (var item in grid.Items)
        {
            var row = (DataGridRow)grid.ItemContainerGenerator.ContainerFromItem(item);
            if (row == null) continue;
            if (row.TransformToVisual(grid).Transform(new Point(0, 0)).Y + row.ActualHeight >= grid.ActualHeight) break;
            var item = (ItemParameter)row.DataContext;
            VisibleRows.Add(qdf.Qdf);
        }
        var vm = (ItemsPaneViewModel)DataContext;
        var checkBox = (CheckBox)sender;
        if (checkBox.IsChecked == null) return;
        var value = checkBox.IsChecked.Value;
        foreach (var ItemParameter in vm.ItemParameters)
        {

            if (VisibleRows.Contains(ItemParameter.Name))
                ItemParameter.IsEnable = value;
        }
    }

谢谢!

0 个答案:

没有答案