Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalidate CollectionViewSource

Tags:

c#

.net

wpf

xaml

I've defined the following view:

<CollectionViewSource x:Key="PatientsView" Source="{Binding Source={x:Static Application.Current}, Path=Patients}"/>

Where Patient is the following property:

public IEnumerable<Patient> Patients
{
    get
    {
        return from patient in Database.Patients
               orderby patient.Lastname
               select patient;
    }
}

Somewhere in my code, I change the Patients database, and I want to have the controls that display this data (using the "PatientsView") to be automatically notified. What's a proper way to do this? Can the CollectionViewSource be invalidated or something?

like image 479
Robbert Dam Avatar asked Jun 29 '26 23:06

Robbert Dam


1 Answers

How to invalidate a CollectionViewSource in code behind:

CollectionViewSource patientsView = FindResource("PatientsView") as CollectionViewSource;
patientsView.View.Refresh();
like image 157
Wallstreet Programmer Avatar answered Jul 02 '26 12:07

Wallstreet Programmer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!