diff --git a/demo/Ursa.Demo/Pages/PopConfirmDemo.axaml b/demo/Ursa.Demo/Pages/PopConfirmDemo.axaml
index acb5216..bee6bb4 100644
--- a/demo/Ursa.Demo/Pages/PopConfirmDemo.axaml
+++ b/demo/Ursa.Demo/Pages/PopConfirmDemo.axaml
@@ -9,9 +9,23 @@
x:DataType="viewModels:PopConfirmDemoViewModel"
x:Class="Ursa.Demo.Pages.PopConfirmDemo">
+
+ ConfirmCommand="{Binding ConfirmCommand}"
+ CancelCommand="{Binding Path=CancelCommand}" >
+
+
+
+
+
+
+
+
diff --git a/demo/Ursa.Demo/ViewModels/PopConfirmDemoViewModel.cs b/demo/Ursa.Demo/ViewModels/PopConfirmDemoViewModel.cs
index 175a8c9..925705a 100644
--- a/demo/Ursa.Demo/ViewModels/PopConfirmDemoViewModel.cs
+++ b/demo/Ursa.Demo/ViewModels/PopConfirmDemoViewModel.cs
@@ -7,27 +7,42 @@ using Ursa.Controls;
namespace Ursa.Demo.ViewModels;
-public partial class PopConfirmDemoViewModel: ObservableObject
+public class PopConfirmDemoViewModel : ObservableObject
{
- internal WindowToastManager? ToastManager { get; set; }
-
- public ICommand ConfirmCommand { get; }
- public ICommand CancelCommand { get; }
-
public PopConfirmDemoViewModel()
{
- ConfirmCommand = new AsyncRelayCommand(OnConfirm);
+ AsyncConfirmCommand = new AsyncRelayCommand(OnConfirmAsync);
+ AsyncCancelCommand = new RelayCommand(OnCancelAsync);
+ ConfirmCommand = new RelayCommand(OnConfirm);
CancelCommand = new RelayCommand(OnCancel);
}
-
- private async Task OnConfirm()
- {
- await Task.Delay(3000);
- ToastManager?.Show(new Toast("Confirmed"), type: NotificationType.Success, classes: ["Light"]);
- }
-
+
+ internal WindowToastManager? ToastManager { get; set; }
+
+ public ICommand ConfirmCommand { get; }
+ public ICommand CancelCommand { get; }
+
+ public ICommand AsyncConfirmCommand { get; }
+ public ICommand AsyncCancelCommand { get; }
+
private void OnCancel()
{
- ToastManager?.Show(new Toast("Canceled"), type:NotificationType.Error, classes: ["Light"]);
+ ToastManager?.Show(new Toast("Canceled"), NotificationType.Error, classes: ["Light"]);
+ }
+
+ private void OnConfirm()
+ {
+ ToastManager?.Show(new Toast("Confirmed"), NotificationType.Success, classes: ["Light"]);
+ }
+
+ private async Task OnConfirmAsync()
+ {
+ await Task.Delay(3000);
+ ToastManager?.Show(new Toast("Async Confirmed"), NotificationType.Success, classes: ["Light"]);
+ }
+
+ private void OnCancelAsync()
+ {
+ ToastManager?.Show(new Toast("Async Canceled"), NotificationType.Error, classes: ["Light"]);
}
}
\ No newline at end of file
diff --git a/src/Ursa.Themes.Semi/Controls/PopConfirm.axaml b/src/Ursa.Themes.Semi/Controls/PopConfirm.axaml
index 7740c6c..6d8f92f 100644
--- a/src/Ursa.Themes.Semi/Controls/PopConfirm.axaml
+++ b/src/Ursa.Themes.Semi/Controls/PopConfirm.axaml
@@ -12,7 +12,7 @@
ContentTemplate="{TemplateBinding ContentTemplate}" />
diff --git a/src/Ursa/Controls/PopConfirm/PopConfirm.cs b/src/Ursa/Controls/PopConfirm/PopConfirm.cs
index a4d13ef..3c73cf6 100644
--- a/src/Ursa/Controls/PopConfirm/PopConfirm.cs
+++ b/src/Ursa/Controls/PopConfirm/PopConfirm.cs
@@ -201,8 +201,11 @@ public class PopConfirm : ContentControl
protected override bool RegisterContentPresenter(ContentPresenter presenter)
{
var result = base.RegisterContentPresenter(presenter);
- _childChangeDisposable = presenter.GetPropertyChangedObservable(ContentPresenter.ChildProperty)
- .Subscribe(OnChildChanged);
+ if (result)
+ {
+ _childChangeDisposable = presenter.GetPropertyChangedObservable(ContentPresenter.ChildProperty)
+ .Subscribe(OnChildChanged);
+ }
return result;
}