使CollectionViewSource无效

Rob*_*Dam 2 .net c# wpf xaml

我已经定义了以下视图:

<CollectionViewSource x:Key="PatientsView" Source="{Binding Source={x:Static Application.Current}, Path=Patients}"/>
Run Code Online (Sandbox Code Playgroud)

患者是以下财产:

public IEnumerable<Patient> Patients
{
    get
    {
        return from patient in Database.Patients
               orderby patient.Lastname
               select patient;
    }
}
Run Code Online (Sandbox Code Playgroud)

在我的代码中的某处,我更改了患者数据库,我希望自动通知显示此数据的控件(使用"PatientsView").这样做的正确方法是什么?CollectionViewSource可以失效吗?

Wal*_*mer 8

如何在后面的代码中使CollectionViewSource无效:

CollectionViewSource patientsView = FindResource("PatientsView") as CollectionViewSource;
patientsView.View.Refresh();
Run Code Online (Sandbox Code Playgroud)