WPF中login窗口验证通过后,展示主页面

1、App.xaml中修改ShutdownMode="OnExplicitShutdown"

<Application x:Class="SBCSML2Client.App"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

xmlns:local="clr-namespace:SBCSML2Client"

ShutdownMode="OnExplicitShutdown" >

<Application.Resources>

<ResourceDictionary>

<FontFamily x:Key="iconfont">

pack://application:,,,/SBCSML2Client;component/Assets/Fonts/#iconfont

</FontFamily>

<ResourceDictionary.MergedDictionaries>

<ResourceDictionary Source="Resources/MergeDictionary.xaml"/>

<!--<ResourceDictionary Source="CommandPage/MenuItemButton.xaml"/>-->

<ResourceDictionary Source="Assets/Styles/GlobalStyles.xaml"/>

</ResourceDictionary.MergedDictionaries>

</ResourceDictionary>

</Application.Resources>

</Application>

2、login界面点击登录按钮连接数据库,验证用户密码

void BtnLogin()

{

DBHandle.InitDB();

DBHandle.ConnToDB();

if (DBHandle.CheckUser(SysInfo))

{

DBHandle.InitLogging();

LoggingDriver.info("HMI Start!!!");

_window.DialogResult = true;

DBHandle.sysInfo = SysInfo;

}

else

{

MessageBox.Show("账号或者密码输入错误,请重新输入!", "消息提示", MessageBoxButton.OK, MessageBoxImage.Warning);

return;

}

}

3、 App.xaml.cs中添加代码,其中LoginWindow是登录界面,MainWindow是主界面。

public partial class App : Application

{

protected override void OnStartup(StartupEventArgs e)

{

base.OnStartup(e);

if (new LoginWindow().ShowDialog() == true)

{

new MainWindow().ShowDialog();

}

Application.Current.Shutdown();

}

}

相关推荐
光泽雨1 天前
控件Password附加属性
wpf
zdr尽职尽责4 天前
UnityCli 兼容2022版本
ui·unity·ai·c#·游戏引擎
辰小忆5 天前
11 · RunCurveChart —— 实时运行曲线
c++·ui·duilib
samble6 天前
从零搭建半导体设备上位机(十二):参数设置页,表单校验、范围校验与配方联动
wpf·数据校验·validationrule
敲上瘾7 天前
Qt核心机制:信号与槽详解
开发语言·c++·qt·ui·qt6.3
FRing038 天前
vue2干货总结10(json-server、vant-ui、postcss插件、axios二次封装、图形验证码、toast轻提示)
开发语言·前端·vue.js·ui·json·vue2·postcss
xy34539 天前
Axure 9.0 垂直菜单介绍
ui·产品经理·axure·原型设计
Oll Correct11 天前
Adobe illustrator 案例十四:花元素标志草图绘制
笔记·ui·adobe·illustrator
huaqianzkh12 天前
WinForm C#:循环修改控件UI闪烁卡顿?SuspendLayout / ResumeLayout 与 BeginUpdate 优化
开发语言·ui·c#
Oll Correct13 天前
Adobe illustrator 案例十三:adidas标志草图绘制
笔记·ui·adobe·illustrator