Skip to content

Common WPF Error “The dynamic resource ‘resource’ could not be resolved.”

November 5, 2015

If you ever receive the following error message during compilation, stating The dynamic resource ‘resource’ could not be resolved, and Visual Studio just won’t compile no matter what. Not only it is dependent on the local path set in the XAML  based here which is right for example: –

<Window x:Class=”SampleApplication.BackOffice.Views.SalesView”
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml&#8221;
xmlns:local=”clr-namespace:SampleApplication.BackOffice.Common”
Title=”Back Office” MinHeight=”600″ MinWidth=”1000″ BorderThickness=”2″>
<Window.Resources>
<local:VisibilityConverter x:Key=”VisibilityConverter” />
</Window.Resources>

——————-

——————-

——————-

You set that if you have set the namespace in the project to SampleApplication.BackOffice.Common for VisibilityConverter class, even though it says it cannot find it, it is fundamentally correct.

However, it is here that is the problem!!!!!! As I later found out, you must add in App.xaml inside the file, the following: – 

<Application x:Class=”SampleApplication.BackOffice.App”
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”&gt;
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source=”Resources\Buttons.xaml”/>
<ResourceDictionary Source=”Resources\ComboBoxes.xaml”/>

</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

Basically inside the ResourceDictionary tags, any of the resource XAMLs that SampleApplication.BackOffice.Views.SalesView window needs, once those buttons or another UI elements are found in those XAML entries, it should work!

Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: