L
L
Lapish722020-08-17 10:23:07
C++ / C#
Lapish72, 2020-08-17 10:23:07

Reactive IObservable binding?

Hello! Dealing with ReactiveUI + DynamicData(SourceList, SourceCache).

I am making a validation class and I need to bind IsValid to a collection. If the collection has at least 1 element, then IsValid = false.

private readonly SourceList<ValidationResult> _results;
public IObservable<bool> IsValid

public ValidationManager() 
{
  _results = new SourceList<ValidationResult>();
  IsValid = _results.Connect().IsEmpty();	

  //Насколько я понял такой вариант можно применить к свойствам, но не к коллекциям
  IsValid = this.WhenAnyValue(x => x._results).Select(x => x.Count == 0);
}


As I understand it, if I want to subscribe to changes in the collection, then I need to add .Subscribe(), but so far I can't implement it.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question