阻止 UI 单击 Caliburn.Micro,WPF
Blocking UI on click in Caliburn.Micro, WPF
如何在 Caliburn.Micro
中屏蔽 UI?
public async void AcceptButton()
{
await this.httpDataService.Register(account);
Show.SuccesBox(alert);
this.TryClose();
}
如何通过阻止 View
在我的 ViewModel
中等待 Task
结束?
编辑
我在 xaml
中的按钮上添加了绑定:
IsEnabled="{Binding isEnabled}"
然后,我的 VM
:
bool isEnabled {get;set;}
public async void AcceptButton()
{
this.isEnabled = false;
await this.httpDataService.Register(account);
Show.SuccesBox(alert);
this.TryClose();
}
在这种情况下,AcceptButton
始终处于非活动状态 IsEnabled=false
。如何仅在单击按钮时触发 false
?
because i dont want to user double-tap "Send form" button
这样做的标准方法就是禁用按钮。或者,如果您想禁用整个表单,则禁用整个 window:
public async void AcceptButton()
{
this.IsEnabled = false;
await this.httpDataService.Register(account);
Show.SuccesBox(alert);
this.TryClose();
}
您应该将 IsEnabled
属性 添加到视图模型 class,然后将其绑定到视图的 IsEnabled
属性。
禁用 window 对用户来说比无响应的应用程序更好,因为这种方法允许用户将其最小化或在它花费了意外的长时间时将其移开。
如何在 Caliburn.Micro
中屏蔽 UI?
public async void AcceptButton()
{
await this.httpDataService.Register(account);
Show.SuccesBox(alert);
this.TryClose();
}
如何通过阻止 View
在我的 ViewModel
中等待 Task
结束?
编辑
我在 xaml
中的按钮上添加了绑定:
IsEnabled="{Binding isEnabled}"
然后,我的 VM
:
bool isEnabled {get;set;}
public async void AcceptButton()
{
this.isEnabled = false;
await this.httpDataService.Register(account);
Show.SuccesBox(alert);
this.TryClose();
}
在这种情况下,AcceptButton
始终处于非活动状态 IsEnabled=false
。如何仅在单击按钮时触发 false
?
because i dont want to user double-tap "Send form" button
这样做的标准方法就是禁用按钮。或者,如果您想禁用整个表单,则禁用整个 window:
public async void AcceptButton()
{
this.IsEnabled = false;
await this.httpDataService.Register(account);
Show.SuccesBox(alert);
this.TryClose();
}
您应该将 IsEnabled
属性 添加到视图模型 class,然后将其绑定到视图的 IsEnabled
属性。
禁用 window 对用户来说比无响应的应用程序更好,因为这种方法允许用户将其最小化或在它花费了意外的长时间时将其移开。