Click here to Skip to main content
15,796,984 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this.WhenyAny is not working for me when I try to check the count of ObservableCollection.

SampleCommand = new ReactiveCommand(this.WhenAny(c => c.TaskList, ((task) => task.Value != null && task.Value.Count > 0)));

 private ObservableCollection<Task> _taskList;

 public ObservableCollection<Task> TaskList
        get { return _taskList; }
        set { this.RaiseAndSetIfChanged(ref _taskList, value); }

I believe the condition is never satisfied as the functionality inside the command is never executed.

My original requirement is whenever the properties of this collection changes, I want to assign it to ObservablePropertyHelper type- isTaskUpdationInitiated. I have implemented the same as below

this.WhenAny(x => x.TaskList,  (z) => z.Value.Count > 0 && ( z.Value.Any(y =>
            ( y.Id  == TaskId &&  y.Prop1 != MyProp1Value &&
             y.Prop2 != MyProp2Value && y.Prop3 != MyProp3Value)
             ))).ToProperty( this, x=>x.IsTaskUpdationInitiated , out isTaskUpdationInitiated );

So whenever these conditions are satisfied, isTaskUpdationInitiated should be set to true. As this was not working, i tried a sample code that I have given intially. Please help!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900