If CleanCommand is executing then SearchCommand will be inactive. If SearchCommand is executing then CleanCommand will be inactive.
Barcode is
public long Barcode
{
get => _barcode;
set => this.RaiseAndSetIfChanged(ref _barcode, value);
}
private readonly ObservableAsPropertyHelper<bool> _isSearching;
private readonly ObservableAsPropertyHelper<bool> _isCleaning;
public bool IsSearching => _isSearching.Value;
public bool IsCleaning => _isCleaning.Value;
public ReactiveCommand<Unit, Unit> SearchCommand { get; }
public ReactiveCommand<Unit, Unit> CleanCommand { get; }
In constructor
SearchCommand = ReactiveCommand.CreateFromObservable(Search, SearchCanExecute());
SearchCommand.IsExecuting.ToProperty(this, x => x.IsSearching, out _isSearching);
CleanCommand = ReactiveCommand.CreateFromObservable(Clean, CleanCanExecute());
CleanCommand.IsExecuting.ToProperty(this, x => x.IsCleaning, out _isCleaning);
In class
IObservable<bool> SearchCanExecute()
{
bool isCleaningSuited = !IsCleaning;
bool isBarcodeSuited = Barcode > 0;
return Observable.Return(isBarcodeSuited);
}
IObservable<bool> CleanCanExecute()
{
bool isSearchingSuited = !IsSearching;
return Observable.Return(isSearchingSuited);
}
I get the process status with *IsExecuting.ToProperty()
I get values with properties like Barcode.
Should i use WhenAny* method or can i do it this way?