0
我寫了最簡單的WPF Prism應用程序。它不關機。WPF Prism應用程序不關機
的App.xaml
<Application x:Class="PrismApp.Desktop.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Shell.xaml"
ShutdownMode="OnMainWindowClose">
<Application.Resources>
</Application.Resources>
</Application>
App.xaml.cs
namespace PrismApp.Desktop
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
Bootstrapper bootstrapper = new Bootstrapper();
bootstrapper.Run();
}
}
}
Bootstrapper.cs
namespace PrismApp.Desktop
{
class Bootstrapper : UnityBootstrapper
{
protected override System.Windows.DependencyObject CreateShell()
{
var shell = new Shell();
return shell;
}
protected override void ConfigureModuleCatalog()
{
base.ConfigureModuleCatalog();
}
}
}
Shell.xaml
<Window x:Class="PrismApp.Desktop.Shell"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Shell" Height="350" Width="525">
<Grid>
</Grid>
</Window>
爲什麼會是這種情況?
只需從App.xaml中刪除StartupUri =「Shell.xaml」,看看發生了什麼?你仍然不允許引導程序加載你的Shell並且讓StartupUri結束。 – 2012-01-12 05:36:03
初創Uri是你的問題。 Theck出這個[交] [1] [1]:http://stackoverflow.com/questions/4114956/prism-app-does-not-exit-when-closed/11987246 #11987246 – Adys 2012-08-16 13:06:20