In App.xaml (no StartupUri):
...
<Application.Resources>
<ResourceDictionary Source="AppResources.xaml"/>
</Application.Resources>
...
This does work but declaring the ResourceDictionary
directly in Application.Resources
does not:
...
<Application.Resources >
<ResourceDictionary>
...
</ResourceDictionary>
</Application.Resources>
...
OnStartup in App.xaml.cs:
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
if (e.Args.Length > 0)
{
// Handle args and start headless.
}
else
{
// Create window.
new Views.ShellWindow().ShowDialog();
}
this.Shutdown();
}
How can this behaviour be fixed?
Edit: I am using Visual Studio 2013 Professional.
Apparently, there is a VS code generation bug where the code necessary to connect to the rest of the program sometimes is not inserted when
A possible workaround is to use an event instead of overriding OnStartup, see WPF - App.xaml file does not get parsed if my app does not set a StartupUri? for more information.