1using System.Windows.Input;
18 TapGestureRecognizer TapRecognizer =
new();
19 TapRecognizer.Tapped += this.OnTapped;
20 this.GestureRecognizers.Add(TapRecognizer);
23 readonly WeakEventManager onClickedEventManager =
new();
28 public static readonly BindableProperty
CommandProperty = ButtonElement.CommandProperty;
57 void ICommandElement.CanExecuteChanged(
object? sender, EventArgs e) => this.RefreshIsEnabledProperty();
59 void IButtonElement.PropagateUpClicked() => this.onClickedEventManager.HandleEvent(
this, EventArgs.Empty, nameof(
Clicked));
61 protected override bool IsEnabledCore => base.IsEnabledCore && CommandElement.GetCanExecute(
this);
68 add => this.onClickedEventManager.AddEventHandler(value);
69 remove => this.onClickedEventManager.RemoveEventHandler(value);
72 private async
void OnTapped(
object? Sender, EventArgs e)
77 VisualStateManager.GoToState(
this, ButtonElement.PressedVisualState);
80 TaskCompletionSource<bool> AnimationTask =
new();
83 this.Animate(
"Blink",
new Animation()
85 { 0, 0.5,
new((value) => this.Scale = value, 1, 0.95, Easing.CubicOut) },
86 { 0.5, 1,
new((value) => this.Scale = value, 0.95, 1, Easing.CubicOut) },
88 finished: (value, isCompleted) => AnimationTask.SetResult(isCompleted));
93 VisualStateManager.GoToState(
this, VisualStateManager.CommonStates.Normal);
95 ButtonElement.ElementClicked(
this,
this);
Base class that references services in the app.
static ILogService LogService
Log service.