剛剛開始使用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我在哪裏修復你的線 –