我有一个关于WPF的StartUp网址的问题。我有一个LoginView.xaml和一个MainWindow.xaml。我想先打开LoginView,然后再自动打开MainWindow。
App.xaml
<Application x:Class="XXX.App"
xmlns="....."
Startup="App_Startup"
>App.xaml.cs
/
// <summary>
/// Called when the application starts.
/// </summary>
private void App_Startup(object sender, StartupEventArgs e)
{
LoginView frmLogin = new LoginView();
bool? resultScreen = frmLogin.ShowDialog();
if (frmLogin.ShowDialog())
{
Uri uri = new Uri("pack:/MainWindow.xaml", UriKind.RelativeOrAbsolute);
Application.Current.StartupUri = uri;
}
else
{
Application.Current.Shutdown();
}
}LoginView窗口正常打开,之后什么也没有发生,应用程序关闭。
我尝试了另一种方法,但得到了相同的结果。
App.xaml
<Application x:Class="XXX.App"
xmlns="....."
Startup="App_Startup"
>App.xaml.cs
/// <summary>
/// Called when the application starts.
/// </summary>
private void App_Startup(object sender, StartupEventArgs e)
{
LoginView frmLogin = new LoginView();
bool? resultScreen = frmLogin.ShowDialog();
if frmLogin.ShowDialog())
{
MainWindow frmMainWindow = new MainWindow();
frmMainWindow.ShowDialog();
}
else
{
Application.Current.Shutdown();
}
}谁能告诉我,我怎样才能得到想要的结果?提前谢谢。
发布于 2009-05-27 09:54:38
我又一次找到了我的问题的解决方案:)这是解决方案
http://www.ageektrapped.com/blog/the-wpf-application-class-overview-and-gotcha/
https://stackoverflow.com/questions/914360
复制相似问题