Filter a DataGrid in WPF

后端 未结 5 2090
庸人自扰
庸人自扰 2020-12-05 08:21

I load a lists of objects in a datagrid with this:

dataGrid1.Items.Add(model);

The model become data from a database. It has a

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-05 08:51

    take at look at DataBinding --> in your case dont add items to your grid, but set the itemssource

    
    

    or

    dataGrid1.ItemsSource = this._myCollectionOfModels;
    

    and if you want some kind of filtering,sorting, grouping look at CollectionView

提交回复
热议问题