How do I Filter ListView in WPF?

前端 未结 1 1166
有刺的猬
有刺的猬 2021-01-03 05:47

I have a ListView bound to a collection of items. I do not want to show the items where the property IsDeleted = \"1\". How can I accomplish this?

1条回答
  •  迷失自我
    2021-01-03 06:17

    I'd use a CollectionView and set the Filter property to an expression:

    var view = CollectionViewSource.GetDefault(GetData());
    view.Filter = i => ((MyType)i).IsDeleted != 1;
    MyListView.DataSource = view;
    

    0 讨论(0)
提交回复
热议问题