Skip to content

[Question] Observe Method to CanExecute ReactiveCommand #2804

Answered by glennawatson
Tenjim asked this question in Q&A
Discussion options

You must be logged in to vote

You can do

var canExecute = this.WhenAnyValue(x => x.MessageText).Select(x => x?.Length > 10)

You could also use a method like

var canExecute = this.WhenAnyValue(x => x.MessageText).Select(x => IsValidMessage(x));

private bool IsValidMessage(string message) 
{
   return message?.Length > 10;
}

Also use the GitHub discussions tab in the future if you have questions rather than a issue.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Tenjim
Comment options

@heronbpv
Comment options

@Tenjim
Comment options

Answer selected by Tenjim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #2803 on June 23, 2021 17:55.