刚刚开始使用C#和VS社区2017年WPF。试图运行代码,将改变启动窗口。 但获得以下例外。WPF C#资源无法找到
System.IO.IOException: 'Cannot locate resource 'application_startup'.'
这个代码是从所述的App.xaml
<Application x:Class="StartUp_Window.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:StartUp_Window"
StartupUri="Application_Startup">
<Application.Resources>
</Application.Resources>
这是从App.xaml.cs
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace c
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
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 for fs";
// Show the window
wnd.Show();
}
}
}
这是来自MainWindow.xaml
<Window x:Class="StartUp_Window.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:StartUp_Window"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
</Grid>
这也是从MainWindow.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace StartUp_Window
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}
这是在App.xaml文件改变的StartupUri后出现的新的错误。
严重性代码说明项目文件的线路抑制状态 错误CS1061“应用”不包含“Application_Startup”的定义,并没有扩展方法“Application_Startup”接受式“应用程序”的第一个参数可以找到(是否缺少)使用指令或程序集引用?)StartUp_Window C:\ Users \ faisal \ Documents \ Visual Studio 2017 \ Projects \ WPF_Tutorial \ StartUp_Window \ StartUp_Window \ App.xaml 5活动 错误CS0246类型或命名空间名称“MainWindow”不能(缺少使用指令或程序集引用?)StartUp_Window C:\ Users \ faisal \ Documents \ Visual Studio 2017 \ Projects \ WPF_Tutorial \ StartUp_Window \ StartUp_Window \ App.xaml.cs 20活动 错误CS0246类型或名称空间名字'MainWindow'找不到(你是mi )StartUp_Window C:\ Users \ faisal \ Documents \ Visual Studio 2017 \ Projects \ WPF_Tutorial \ StartUp_Window \ StartUp_Window \ App.xaml.cs 20活动
还需要StartupUri =“MainWindow。xaml“ – AQuirky
@AQuirky这是真的,我会编辑它 –
@AQuirky我在哪里修复你的线 –