修改窗体模式
<Application x:Class="Zhaoxi.CourseManagement.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Zhaoxi.CourseManagement"
ShutdownMode="OnExplicitShutdown">
<Application.Resources>
</Application.Resources>
</Application>
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
if(new LoginView().ShowDialog() == true)
{
new MainView().ShowDialog();//登陆窗口关闭打开
}
Application.Current.Shutdown();//主窗口关闭推出程序
}
}
界面
<Button Content="登 录" Grid.Row="3" Height="42" Foreground="White" FontSize="16"
Template="{StaticResource LoginButtonTemplate}"
Command="{Binding LoginCommand}"
CommandParameter="{Binding ElementName=window}"/>
Application.Current.Dispatcher.Invoke(new Action(() =>
{
(o as Window).DialogResult = true;
}));