Search code examples
c#.netwpfobservablecollectioncollectionviewsource

How to observe a related ViewSource?


In a WPF XAML I have

<CollectionViewSource
    x:Key="aViewSource"
    d:DesignSource="{d:DesignInstance my1:TableA, CreateList=True}" />
<CollectionViewSource
    x:Key="anotherViewSource"
    Source="{Binding Path=ANOTHER, Source={StaticResource aViewSource}}" />

In the xaml.cs I have

var aViewSource = (CollectionViewSource)this.FindResource("aViewSource");
var tableA = new ObservableCollection<TableA>(
    this.entities.TableA
        .Where(predicate)
        .Take(10)
        .ToList());
tableA.CollectionChanged += this.NotifyCollectionChangedEventHandler;
fibrasViewSource.Source = tableA;

How can I observe anotherViewSource?


Solution

  • I abandoned ViewSource altogether since I saw no advantages on using it.