大概思路,使用ShowDialog弹出登录界面,验证账号密码成功,给DialogResult赋值为true①,同时显示登录成功后的主界面。
以下是实现方法:
一、删除StartupUri,加上ShutdownMode="OnExplicitShutdown"②,重写应用程序的OnStartup 方法,在App.xaml里面
<Application x:Class="GasSystem.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:GasSystem"
StartupUri="Views/LoginView.xaml">
改成
<Application x:Class="GasSystem.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:GasSystem"
ShutdownMode="OnExplicitShutdown">