排序后,WPF c#Filter无法正常工作

时间:2013-06-17 06:55:59

标签: c# wpf sorting filtering

我有一个WPF Gridview和三个按钮。两个Sort和一个应用过滤器。他们都独立工作。问题是,排序后,我必须再次单击过滤器按钮,然后再单击排序按钮以使过滤器应用。我希望通过Items.SortDescriptions和Items.Refresh()来实现这一点。如果没有,我相信你会告诉我,我会添加更多。

    private void btnApply_Click(object sender, RoutedEventArgs e){
        DataList.Clear();
        foreach(FilterItem f in FilterList){
            if (f.isChecked && listBox.Items.IndexOf(f) > -1 ) {
                DataList.Add(f.Name);
            }
        }
        myListView.Items.Refresh();
        this.contextFilter.IsOpen = false;
    }

    private void btnSortAsc_Click(object sender, RoutedEventArgs e){
        SortDescription sa = new SortDescription("", System.ComponentModel.ListSortDirection.Ascending);
        myListView.Items.SortDescriptions.Clear();
        myListView.Items.SortDescriptions.Add(sa);
        this.contextFilter.IsOpen = false;
    }

    private void btnSortDec_Click(object sender, RoutedEventArgs e){
        SortDescription sd = new SortDescription("", System.ComponentModel.ListSortDirection.Descending);
        myListView.Items.SortDescriptions.Clear();
        myListView.Items.SortDescriptions.Add(sd);
        this.contextFilter.IsOpen = false;
    }

0 个答案:

没有答案
相关问题