gpt4 book ai didi

c# - 在主窗口之前显示登录窗口

转载 作者:太空狗 更新时间:2023-10-29 23:23:25 29 4
gpt4 key购买 nike

在我的 wpf 应用程序中,我想在 sturtup 显示登录表单,如果用户输入有效的用户名和密码,将显示 window1。我在我的 app.xmal 中使用此代码:

<Application x:Class="Acountant.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Startup="Application_Startup">

和 app.xmal.cs 中的这段代码:

    private void Application_Startup(object sender, StartupEventArgs e)
{
LoginFRM f = new LoginFRM();

if (f.ShowDialog() == true)
{
var frm = new Window1();
frm.ShowDialog();
}
}

但是我的申请关闭了!

最佳答案

您应该将 Application.ShutdownMode 设置为 OnExplicitShutdown ( msdn )。

例子:

<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml"
ShutdownMode="OnExplicitShutdown"
>
</Application>

关于c# - 在主窗口之前显示登录窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17909673/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com