You must Sign In to post a response.
  • Category: LINQ

    This.WhenAny not working for ObservableCollection

    this.WhenyAny is not working when I try to check the count of ObservableCollection.

    Collapse | Copy Code
    SampleCommand = new ReactiveCommand(this.WhenAny(c => c.TaskList, ((task) => task.Value != null && task.Value.Count >

    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

    Collapse | Copy Code
    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!
  • #752194
    Are you getting nay error on the same, since I have observed no error using WhenAny in a collection object.
    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM

  • #753317
    Here WhenAny returns a task that identifies the first task in a collection of tasks to complete.

    It returns the first process that completes

    Miss. Jain
    Microsoft Certified Technology Specialist in .Net

  • Sign In to post your comments