2016-07-07 7 views
1

私はちょうどWPFを開始しました。私はコードの後ろにstartupURIページを割り当てています。それは私に、このエラーを与える:リソース 'application_startup'を見つけることができません

ここ

Cannot locate resource '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> 

で行うものです私は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(); 
    } 

この簡単なコードで何が問題なのかお手伝いします。ありがとう

+4

イベント名は「StartupUri」ではなく、「StartupUri」です(これはプロパティです)。正しくハンドラを購読してください: 'Startup =" Application_Startup "' – ASh

+0

これは働いています。 –

答えて

3

StartupUriは、アプリケーションの起動時に読み込まれるウィンドウオブジェクトのファイル名を指定するために使用されます。 Startupは、アプリケーションの起動中に何かしたい場合に購読するイベントです。

2

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> 
関連する問題