今天在vs2008的平台下,调试wpf程序,发现在Blend中可以随意的设置启动项,但是vs不行,等我添加了一段网上找到的代码:
public static void Main()
{
App app = new App();
app.ShutdownMode = ShutdownMode.OnExplicitShutdown;
app.Run();
}
private void win_Closed(object sender, System.EventArgs e)
{
Application.Current.Shutdown();
}
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
Window winDlg = new Window();
winDlg.ShowInTaskbar = false;
winDlg.WindowStartupLocation = WindowStartupLocation.CenterScreen;
bool? dlgResult = winDlg.ShowDialog();
if (dlgResult.Value == true)
{
Window winmain = new Window();
this.MainWindow = winmain;
winmain.WindowStartupLocation = WindowStartupLocation.CenterScreen;
winmain.Closed += new EventHandler(win_Closed);
winmain.Title = "欢迎使用广药交互式教学平台";
winmain.Show();
}
else
{
Application.Current.Shutdown();
}
}
这时候出现问题了,一个在wpf项目中没显示的app.g.cs跑出来了,原来设置启动项的地方这里就有了,但是他是在Bin/Debug下面项目中找不到的!记住了!