Reputation: 338
I have a model like this:
public class product
{
public int id;
public string name;
public bool show;
}
Also I have a list with this model:
List<product> list;
bind:
dataGrid.ItemsSource = list;
Each item of 'list' that have this condition:
if (product.show == false)
shouldn't display in Datagrid.
Please Help Me. Thanks
Upvotes: 0
Views: 39
Reputation: 479
try this:
List<product> sortedList = list.Where(item => item.show != false).ToList();
dataGrid.ItemsSource =sortedList;
Upvotes: 1
Reputation: 2469
Try like this :
dataGrid.ItemsSource = list.Where(ro => ro.show != false).ToList();
Upvotes: 2