I have two assemblies that each provide a common set of styles and resources that I want to include in my application. I'm using merged dictionaries in my App.xaml
in order to load them, and at runtime they were just fine. Unfortunately, these resources won't load at design time, filling my Errors window with messages about unresolvable resources and giving me a UI that doesn't represent what will actually appear.
This is my App.xaml as it stands right now:
<Application x:Class="ClientDebug.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Dai.Common;component/Xaml/Common.xaml" />
<ResourceDictionary Source="/Dai.DevExpress;component/Xaml/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
For both of these merged dictionaries, I get the following errors in my Errors window:
Error 11 An error occurred while finding the resource dictionary "/Dai.Common;component/Xaml/Common.xaml". C:\DevProjects\Core Application\ClientDebug\App.xaml 12 17 ClientDebug
Error 12 An error occurred while finding the resource dictionary "/Dai.DevExpress;component/Xaml/Styles.xaml". C:\DevProjects\Core Application\ClientDebug\App.xaml 13 17 ClientDebug
Which are obviously short on helpful information. Again, they load at runtime just as you'd expect, but none of the resources are available at design time.
I have this every time I start a new WPF project or work with an old one ever since a few days ago. I started a question to ask for help on it, only for it to disappear on me on a test Solution! Seems Visual Studio's not very stable, who knew?
The core of the problem is that the Xaml designer isn't allowing you to make references to other Projects in your Solution from your Application Project only. The workaround is to move everything into a Library and have the Application do little more than hand off control to it in code. Inelegant and the loss of App.Xaml is very tough, but it's much better than waiting for Visual Studio to magically figure it all out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With