mirror of
https://gitee.com/csharpui/CPF.git
synced 2026-06-25 14:54:01 +08:00
Button.AsyncClick
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
using CPF.Controls;
|
||||
using CPF.Toolkit.Input;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace CPF.Toolkit.Controls
|
||||
{
|
||||
public class AsyncButton : Button
|
||||
{
|
||||
|
||||
protected override void InitializeComponent()
|
||||
{
|
||||
base.InitializeComponent();
|
||||
this.Triggers.Add(nameof(IsEnabled), Relation.Me, null, (nameof(Background), "224,224,224"));
|
||||
}
|
||||
|
||||
public IAsyncCommand Command { get; set; }
|
||||
|
||||
protected override async void OnClick(RoutedEventArgs e)
|
||||
{
|
||||
this.IsEnabled = false;
|
||||
base.OnClick(e);
|
||||
if (this.Command != null)
|
||||
{
|
||||
await this.Command.ExecuteAsync();
|
||||
}
|
||||
this.IsEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user