Reputation: 101
I have a simple style in a resource dictionary which is located in a WPFResources.dll, I am accessing this style in another project, I can see that the style is being applied at design time, but when i run the application I am getting an exception that "Cannot find resource named 'IndentCheckBoxStyle'. Resource names are case sensitive"
. if i use the StaticResource then I can see this exception if I use the DynamicResource then I dont see any exception, but nothing is visible on the UI.
More about this issue:
I have referenced the WPFResources.dll in my project and merged it in the App.XAML like this:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/WPFResources;component/Theme.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
And inside the Theme.xaml i have merged the resource dictionary of the cheboxstyle.
Any one have any idea about this ??
Thanks in advance.
Upvotes: 2
Views: 1238
Reputation: 21521
I've had this problem and found that the styles were being applied to the entire application using the Pack URI syntax,
e.g. in App.xaml
<Application x:Class="Framework.Presentation.Preview.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Abt.Framework.Presentation;component/Themes/AbtDark.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
However, an implicit style is not being applied to the top level window in the application (despite MyTheme.xaml containing an unnamed Style for Window)
To resolve this, I've simply used a named style (not implicit style) for the Window. The rest are applying correctly.
Upvotes: 1