How to block UI in Caliburn.Micro
?
public async void AcceptButton()
{
await this.httpDataService.Register(account);
Show.SuccesBox(alert);
this.TryClose();
}
How to wait for end of Task
in my ViewModel
by blocking View
?
EDIT
i added binding on my button in xaml
:
IsEnabled="{Binding isEnabled}"
Then, my VM
:
bool isEnabled {get;set;}
public async void AcceptButton()
{
this.isEnabled = false;
await this.httpDataService.Register(account);
Show.SuccesBox(alert);
this.TryClose();
}
In this case, AcceptButton
is always unactive IsEnabled=false
. How to trigger false
only on button click?
because i dont want to user double-tap "Send form" button
The standard way of doing that is just disabling the button. Or, if you want to disable the entire form, then disable the entire window:
public async void AcceptButton()
{
this.IsEnabled = false;
await this.httpDataService.Register(account);
Show.SuccesBox(alert);
this.TryClose();
}
You should add the IsEnabled
property to your view model class and then bind it to the IsEnabled
property of the view.
Disabling the window is nicer to the user than an unresponsive application, because this approach allows the user to minimize it or move it out of the way if it is taking an unexpectedly long time.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.