How to disable button during it's binded task excute? #13637
-
How to disable button during it's binded task excute? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
If you're using Mvvm Toolkit, this happens by default as [RelayCommand]
public async Task DoTheThing()
{
await Task.Delay(2000);
} <Button Command="{Binding DoTheThingCommand}" Content="Click" /> Otherwise, you need to: manage some state within the body of the command (eg. |
Beta Was this translation helpful? Give feedback.
-
If you are using ReactiveUI this also happens by default when using one of the |
Beta Was this translation helpful? Give feedback.
If you're using Mvvm Toolkit, this happens by default as
AllowConcurrentExecutions
is false by default. eg.Otherwise, you need to: manage some state within the body of the command (eg.
bool IsExecuting
), have your command implementation raiseCanExecuteChanged
, do your task, reset state, raiseCanExecutiveChanged
again so the button is re-enabled. Might be a cleaner way, but depends onICommand
implementation.