我刚刚开始WPF.我正在startupURI从代码后面分配页面.它给了我这个错误:
找不到资源'application_startup'"
这是我在App.xaml中所做的
<Application x:Class="HelloWpf.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Application_Startup">
<Application.Resources>
</Application.Resources>
Run Code Online (Sandbox Code Playgroud)
这是我在App.xaml.cs文件中所做的:
private void Application_Startup(object sender, StartupEventArgs e)
{
// Create the startup window
MainWindow wnd = new MainWindow();
// Do stuff here, e.g. to the window
wnd.Title = "Something else";
// Show the window
wnd.Show();
//Application.Current.MainWindow = wnd;
//wnd.InitializeComponent();
//wnd.Show();
}
Run Code Online (Sandbox Code Playgroud)
请帮助这个简单的代码有什么问题.谢谢
将您的 xaml 更改为以下代码。它应该有效。
<Application x:Class="HelloWpf.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Startup="Application_Startup">
<Application.Resources>
</Application.Resources>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
962 次 |
| 最近记录: |