feat: add CanClose hook to easily block window closing.

This commit is contained in:
rabbitism
2024-10-07 17:53:41 +08:00
parent d0e57ba6ed
commit 8ee920bde4
2 changed files with 27 additions and 0 deletions

View File

@@ -1,3 +1,4 @@
using System.Threading.Tasks;
using Ursa.Controls;
namespace Ursa.Demo.Views;
@@ -8,4 +9,10 @@ public partial class MainWindow : UrsaWindow
{
InitializeComponent();
}
protected override async Task<bool> CanClose()
{
var result = await MessageBox.ShowOverlayAsync("Are you sure you want to exit?", "Exit", button: MessageBoxButton.YesNo);
return result == MessageBoxResult.Yes;
}
}