mirror of
https://gitee.com/csharpui/CPF.git
synced 2025-06-28 13:34:09 +08:00
32 lines
777 B
C#
32 lines
777 B
C#
![]() |
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;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|