the resource "" could not be resolved in design time - silverlight

My resource merged in App.xaml. but in design mode not found
in Run time it found and work correctly
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Assets/Styles/Main.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Style="{StaticResource pnlRibbon}" the resource "pnlRibbon" could not be resolved in design time

Use this syntax:
<ResourceDictionary Source="projectName;component/Assets/Styles/Main.xaml" />

it been solved with add this code to the .csproj file
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>

Related

WPF Merged Dictionaries

i'm trying to use MaterialDesginThemes and HandyControl ResourceDictionary together but after i run my application it seems that it only recognising Handycontrol recourses at then i find out that application resources can only recognize the last line in the recourse dictionary can any one help how to fix this problem
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Blue.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Purple.xaml" />
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml"/>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

Controls styles not found in MahApps 1.1.3-alpha225

I was using the stable version on nuget and changed to 1.1.3-alpha225 also from nuget. I did that so I could call dialogs through the ViewModel. But now I'm getting this error:
An error occurred while finding the resource dictionary "pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml"
All other dictionaries are ok:
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
The controls is the only one giving error:
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml"
Does anyone know if it changed on the new version or if there's a known bug?

Dictionaries not found when using MahApps.Metro

I just created a new project and got the MahApps.Metro from nuget. I added this to my App.xaml:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
But I get one error like this for each ResourceDictionary entry:
An error occurred while finding the resource dictionary "pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml".
But the dictionaries are found because when I run the application the styles are being applied to the controls. It seems to be a design time only error.
Is there any way to hide them? I'm also having errors for each MahApps Style property that I have set in my XAMLs. Since it's a big application my Error List always has ~30 errors.
This is really annoying, because the styles are being applied when the applicatino run, so there's nothing wrong. When I have a real error it turns in a hell to find it in the middle of all of these other 'erros'
I have the same error if i don't have checked "Run project code in XAML Designer (if supported)". Maybe it is a problem.

How can I import a deep hierarchy of merged dictionaries with 1 ResourceDictionary?

I am attempting to merge in dictionaries from a dependent class library project, but the resource keys can't be found. Note: I am using this Connect bug workaround from Microsoft which is supposed to allow the framework to search deep enough to find the nested resources. This does not appear to be working.
Example of Failure
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/MyApplication.ControlLibrary;component/ResourceDictionaries/ResourceLibrary.xaml" />
<ResourceDictionary>
<Style TargetType="{x:Type Line}" /> <!-- workaround from MS to allow for this -->
<Main:AppBootstrapper x:Key="bootstrapper" /> <!-- CaliburnMicro bootstrapper, unsure if this is relevant -->
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Inside ResourceLibrary.xaml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="DefaultColorTheme.xaml" />
<!-- ...snip... -->
<ResourceDictionary Source="TransitionControl.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
When doing this, it cannot find the resource keys. If I merge each dictionary in manually from that class library, it works fine. This, IMO, begins to defeat the purpose of abstracting resources out to an external assembly.
Example of Success
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/MyApplication.ControlLibrary;component/ResourceDictionaries/DefaultColorTheme.xaml" />
<ResourceDictionary Source="/MyApplication.ControlLibrary;component/ResourceDictionaries/Images.xaml" />
<ResourceDictionary Source="/MyApplication.ControlLibrary;component/ResourceDictionaries/FontIcons.xaml" />
<ResourceDictionary>
<Style TargetType="{x:Type Line}" />
<Main:AppBootstrapper x:Key="bootstrapper" />
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Have I placed the dummy implicit style in the wrong place? Something isn't adding up here. Thanks for looking.
I've learned this the hard way by playing around with it for 3 days.
do not make really deep structures. Have a main dictionary that is just using other dictionaries. The app is not supposed to access anything from the others.
But the crucial thing is to reference them in the right order. it wont work if you load a RD where one of it's contents use something from another one that is not already loaded. The order is truly crucial.
Using WPF Inspector will help you a lot since it makes it possible to track everything donw in an WPF app.

How to merge resource files from other assemblies in Silverlight / wp7

In my app i need to merge the resource file from an external assembly. Is it possible to do so? If the answer is yes please guide me to resolve this issue .
Try this:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/StyleResource.Styless;component/ButtonStyle.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>

Resources