我们如何更改 Avalonia 应用程序的默认关闭模式
我正在尝试使用 avalonia(.net 6) 构建跨平台桌面应用程序。实际上我是阿瓦洛尼亚的新手。我想明确关闭我的应用程序。默认关闭模式 OnLastWindowClose ,我想将其更改为 OnExplicitShutdown 。我得到一个提示,它想在 App axaml.cs 的应用程序生命周期中进行配置。但我不知道该怎么做。 任何人请帮助我。请给我详细描述配置它的每个步骤。
Iam trying to build an cross platform desktop application using avalonia(.net 6). Actually Iam new to avalonia. I want to shutdown my application explicitly. The default shutdown mode OnLastWindowClose , I want to change it to OnExplicitShutdown. I got a hint that it want to configure in the Application Lifetime at App axaml.cs . But I don't know how to do it.
Anyone please help me. Please give me a detailed description about each and every step to configure it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过 StartWithClassicDesktopLifetime(T, string[], ShutdownMode)< 在 Main() 中设置它/a> 方法。
EG:在“Avalonia Application”项目模板中,您可以在 Program.cs 中按如下方式设置:
我还在 App.axaml.cs 的 OnFrameworkInitializationCompleted() 中看到了它的设置,但我已经没有测试过...
Avalonia 文档中有一些背景信息:
应用程序生命周期
You can set it in Main() via StartWithClassicDesktopLifetime(T, string[], ShutdownMode) method.
EG: In the "Avalonia Application" project template you can set it as follows in Program.cs:
I've also seen it set in OnFrameworkInitializationCompleted() in App.axaml.cs, but I've not tested it...
There is some background information in the Avalonia documentation:
Application-lifetimes