2016-07-07 24 views
1

Ich habe gerade WPF jetzt gestartet. Ich weise startupURI Seite vom Code zurück zu. Es gibt mir diese Fehlermeldung:Die Ressource 'application_startup' konnte nicht gefunden werden

Cannot locate resource 'application_startup'"

hier ist das, was ich in 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> 

hier getan ist, was ich in App.xaml.cs Datei getan haben:

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(); 
    } 

Bitte helfen Sie, was in diesem einfachen code falsch ist. Danke

+4

Ereignisname ist 'Startup', nicht' StartupUri' (das ist Eigenschaft). Subscribe den Handler richtig: 'Startup =" Application_Startup "' – ASh

+0

das funktioniert. Danke .. –

Antwort

3

StartupUri wird verwendet, um den Dateinamen des Fensterobjekts anzugeben, das beim Start der Anwendung geladen werden soll. Startup ist das Ereignis, das Sie abonnieren müssen, wenn Sie beim Start der Anwendung etwas unternehmen möchten.

2

Ändern Sie Ihre XAML in den unteren Code. Es sollte funktionieren.

<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> 
Verwandte Themen