如果用户登录成功,那么我想显示主窗口,如果没有,我想退出应用程序 [英] If the user logs on successfully, then I want to show the main window, if not, I want to exit the application

查看:32
本文介绍了如果用户登录成功,那么我想显示主窗口,如果没有,我想退出应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想不通的愚蠢的简单问题.

Stupidly simple question I can't figure out.

我有一个 WPF 应用程序,我想先显示一个登录对话框(在主窗口出现之前).

I have a WPF application, and I want to display a Logon dialog box first (before the main window shows up).

如果用户登录成功,那么我想显示主窗口,如果没有,我想退出应用程序.

If the user logs on successfully, then I want to show the main window, if not, I want to exit the application.

如何正确地做到这一点?

How does one do this correctly?

推荐答案

我想我知道我想要做什么了.

I think I figured out what I was trying to do.

1) 我需要将 App.xaml 中的StartupUri"设置为Logon.xaml",其中 Logon.xaml 是我的登录窗口.

1) I needed to set the "StartupUri" in the App.xaml to "Logon.xaml", where Logon.xaml is my logon window.

2) 在 LogonButton_Click 事件处理程序中,我添加了以下内容

2) in the LogonButton_Click event handler, I added the following

if (blnAuthenticateSuccessful) {
    MainWindow main = new MainWindow();
    App.Current.MainWindow = main;
    this.Close();
    main.Show();
}

这似乎完成了我想要的.

This seems to accomplish what I want.

这篇关于如果用户登录成功,那么我想显示主窗口,如果没有,我想退出应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆