Merge pull request #440 from irihitech/window-close

Add CanClose hook for UrsaWindow
This commit is contained in:
Zhang Dian
2024-10-21 10:01:11 +08:00
committed by GitHub
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?\n您确定要退出吗", "Exit", button: MessageBoxButton.YesNo);
return result == MessageBoxResult.Yes;
}
}