Fortmann
Fortmann

Reputation: 443

Visual Studio 2015 XAML Resource Dictionary Error

PART 1 (solved)

The following XAML works fine in Visual Studio 2013 (Premium, Update 5):

<Window.Resources>
  <ResourceDictionary Source="Resources/Dictionaries/Main.xaml" />
</Window.Resources>

However, when working with the same project in Visual Studio 2015 (Enterprise), it complains with the following error:

Exception: An error occurred while finding the resource dictionary "Resources/Dictionaries/Main.xaml".

A different topic concerns a similar error with Visual Studio 2012, and was apparently resolved by installing Update 1 for VS2012.

PART 2

Using the pack URI makes Visual Studio 2015 happy, but unfortunately it is still not applying inhertied styles. Interestingly, in Visual Studio 2013 designer the style is applied correctly, but not in Visual Studio 2015, and also not when the application runs!

Any Ideas?

PART 2 : UPDATE

A further (side issue), that was confusing the main issue was "static resources for the main window are only loaded after the main window definition is processed". This means that default styles (in specific, a window style) must be placed in app.xaml so that they are defined by the time the main window is loaded (otherwise they will not be applied in the designer, or in the application when it runs).

Upvotes: 2

Views: 3257

Answers (1)

Filippo Vigani
Filippo Vigani

Reputation: 1004

Try the following:

<ResourceDictionary Source="pack://application:,,,/YourNamespace;component/Resources/Dictionaries/Main.xaml" />

Upvotes: 3

Related Questions