I want to know how can I update a CollectionViewSource when a button is clicked?
I still have
<Window.Resources>
<CollectionViewSource x:Key="cvsCustomers"
Source="{Binding CustomerCollection}"
Filter="CollectionViewSource_Filter" >
</CollectionViewSource>
</Window.Resources>
What creates a CollectionViewSource ...
<DataGrid HorizontalAlignment="Left"
Height="210"
Margin="47,153,0,0"
VerticalAlignment="Top" Width="410"
ItemsSource="{Binding Source={StaticResource cvsCustomers}}"
CanUserAddRows="False"
What links the source to my datagrid
private void CollectionViewSource_Filter(object sender, FilterEventArgs e)
{
Customer t = e.Item as Customer;
if (t != null)
{
if (t.Name.Contains(txtSearch.Text))
{
e.Accepted = true;
}
else
{
e.Accepted = false;
}
}
}
And the filter in my view,
Everything seems to work (the elements are tied to the grid), but how to update the view or grid so that I can run this function again so that the grid is filtered out? (pressing a button really)
thank
source
share