WhenAnyValue 没有被 RaisePropertyChanged 调用

WhenAnyValue is not getting called by RaisePropertyChanged

我是 ReactiveUI 和 DynamicData 的新手

声明

 ReadOnlyObservableCollection<Employee> itemSource;
     public ReadOnlyObservableCollection<Employee> ItemSource
     {
        get => itemSource;
     }
     SourceList<Employee> Employees = new SourceList<Employee>();

实施

Employees
    .Connect()
    .Sort(SortExpressionComparer<Employee>.Ascending(emp => emp.ID))
    .Bind(out itemSource)
    .ObserveOn(RxApp.MainThreadScheduler)
    .Do(_ =>
         {
              this.RaisePropertyChanged(nameof(ItemSource));
         })
    .DisposeMany()
    .Subscribe()
    .DisposeWith(disposable);

  this.WhenAnyValue(x => x.itemSource)
      .Do(_ =>
    {
        Debug.Print("Called");

    });

但每当我打电话时

Employees.Add(new Employee
  {
    Name = "Hello" + DateTime.Now.ToShortDateString(),
    ID = random.Next(1,1000)
 });

我希望它在调试 window 中打印 "Called",因为应该调用 this.WhenAnyValue,但显然情况并非如此。

如果我做错了什么,你能帮我理解一下吗?

谢谢格伦。我能够使用以下代码修复它

this.WhenAnyValue(x => x.itemSource.Count)
      .Do(_ =>
    {
        Debug.Print("Called");

    });