VS2013: An error occurred while finding the resource dictionary - wpf

I just got VS2013 and opened my VS2010 project. However now I cannot see any of xaml designs. The problem is the Styles are not being applied:
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Themes/Colors.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Gives me the error:
Error 1 An error occurred while finding the resource dictionary "/Themes/Colors.xaml".
This works fine in VS2010. The build option is set to Page. All target frameworks are set to .NET 4.
The directory structure is this:
Host\Themes\Colors.xaml
Plugins\EqPlugin\Source\ProblemFile.xaml
The themes are defined in the VEParameters project and have this declared:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:EQPlugin;assembly=VEParameterTool">
The file where the error occurs is in the EqPlugIn directory and has this declared:
<UserControl x:Class="EQPlugin.EQControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:src="clr-namespace:VEParameterTool;assembly=VEParameterTool"
xmlns:l="clr-namespace:EQPlugin"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:oxy="http://oxyplot.codeplex.com"
mc:Ignorable="d">
I have tried changing the paths to relative paths but that doesn't work, i have removed and re-added the assemblies, i have restarted etc, all projects are build for the same framework. I don't know what else to try.

Try the below one, Provied the assembly name, even if it is in the same assembly
Source="pack://application:,,,/<assemblyName>;component/Themes/Colors.xaml"

Related

WPF ResourceDictionary cannot locate source

My XAML designer keep screaming "Cannot locate resource xxx.xaml". I have tried both pack application and absolute path URI formats
"pack://application:,,,/ReferencedAssembly;component/Subfolder/ResourceFile.xaml"
"pack://application:,,,/Subfolder/ContentFile.xaml"
"/AssemblyName;component/FilePath.xaml"
The project file structure (can't post picture, not enough rep):
root/App.xaml
root/MainWindow.xaml
root/Res
root/Res/PalleteBlue.xaml
root/UserControl
root/UserControl/NavigationDrawer.xaml
root/UserControl/Res
root/UserControl/Res/NavigationDrawerResource.xaml
NavigationDrawer.xaml use NavigationDrawerResource.xaml
MainWindow.xaml have instance of NavigationDrawer.xaml
XAML designer on NavigationDrawer has no issues, but on MainWindow it keep telling Cannot locate resource usercontrol/res/navigationdrawerresource.xaml
Here is resource declaration in NavigationDrawer.xaml
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/UserControl/Res/NavigationDrawerResource.xaml"/>
<ResourceDictionary Source="pack://application:,,,/Res/PalleteBlue.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
And here is how MainWindow.xaml add instance of NavigationDrawer
xmlns:uc="clr-namespace:InfiniteLite.View.UserControl"
<Grid>
<uc:NavigationDrawer></uc:NavigationDrawer>
</Grid>
This yields the Cannot locate resource.... error on <uc:NavigationDrawer> tag but the project can debug just fine

"Live" data in XAML editor window in Visual Studio and running application

I am trying implementing an addin for SparxEA with the MVVM Light. One thing that I found interesting is seeing “live” data in a window as is mentioned in the course of MVVM Light. So, I would like to do the same. As I have Class Library project I can’t use App.XAML.
In XAML I have this code:
<Window x:Class="GoatJira.View.About"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:GoatJira.View"
xmlns:viewmodel="clr-namespace:GoatJira.ViewModel"
mc:Ignorable="d"
Title="{Binding Path=AboutTitle}" Height="322.613" Width="573.608" ResizeMode="NoResize" ShowInTaskbar="False" WindowStartupLocation="CenterScreen" Initialized="Window_Initialized"
DataContext="{Binding Source={StaticResource ResourceKey=AboutData}}"
>
<Window.Resources>
<ResourceDictionary>
<viewmodel:AboutViewModel x:Key="AboutData"/>
</ResourceDictionary>
</Window.Resources>
…
This perfectly works within Visual Studio IDE. When I run the app and want to instantiate the window, I obtain this exception (translated from Czech): Source marked as AboutData was not found. Names of sources are case sensitive.
When I remove the 10th line with DataContext, I can’t see the bind data within the VS, on the other hand, application works fine when I assign the DataContext in code. My understanding is, that there is a way when it works in VS and in running app without changing anything.
Do you have any idea what I am doing wrong?
If needed, the whole code is at https://github.com/SlavekRydval/GoatJira.
What happens if you move the DataContext to after the resource section i.e.
<Window blah=for>
<Window.Resources>
<ResourceDictionary>
<viewmodel:AboutViewModel x:Key="AboutData"/>
</ResourceDictionary>
</Window.Resources>
<Window.DataContext>
<StaticResourceExtension ResourceKey="AboutData"/>
</Window.DataContext>

The type or namespace name could not be found (are you missing a using directive or an assembly reference

I have Downloaded one project from internet when tried to include to my main project It is showing Clr namespace Error Please help me I have already added dll file in reference what should i do ?? Its showing error in SiriusMicrotech clr namespace..
//My Coding//
<Page x:Class="RTBSPROJECT.Point_Of_Sale.Invoice"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ig="http://schemas.infragistics.com/xaml"
xmlns:SiriusMicrotech="clr-namespace:SiriusMicrotech.core.UI"
mc:Ignorable="d"
Title="Invoice" >
enter code here
<Page.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Point Of Sale\TouchStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</page.Resources>
Hi you also need to specify the Assembly along with namespace when you use assembly other than current assembly
xmlns:SiriusMicrotech="clrnamespace:SiriusMicrotech.core.UI;assembly=AssemblyName....."
I hope this will help.

Unknown parser error when try to add resources

I have problem with adding resources to my wp7 project.
I have added
<resources:LocalizedStrings x:Key="LocalizedStrings"/>
and after running application I recieve such XamlParseException: Unknown parser error: Scanner 2147500037.
Here is code.
<Application
x:Class="MyProject.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:vm="clr-namespace:MyProject.ViewModels;assembly=MyProject.ViewModels"
xmlns:resources="clr-namespace:MyProject.Resources;assembly=MyProject.Resources">
<Application.Resources>
<ResourceDictionary>
<resources:LocalizedStrings x:Key="LocalizedStrings"/>
<vm:ViewModelLocator x:Key="Locator"/>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="styles/globalstyles.xaml"/>
<ResourceDictionary Source="styles/UserStyles.xaml"/>
<ResourceDictionary Source="styles/DialogStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
<Application.ApplicationLifetimeObjects>
<shell:PhoneApplicationService
Launching="Application_Launching" Closing="Application_Closing"
Activated="Application_Activated" Deactivated="Application_Deactivated"/>
</Application.ApplicationLifetimeObjects></Application>
Resolve this issue by creating project MyProject.LocalizedResources instead of MyProject.Resources
xmlns:resources="clr-namespace:MyProject.LocalizedResources;assembly=MyProject.LocalizedResources"
This works well now.
Single word Resources in project name leads to the error! :(

Telerik set application theme from XAML

Is it possible to set application wide theme from XAML in Telerik? There is only a code-behind example. I would like to set in in XAML and have a Metro theme in design-mode too.
You could achieve this as follows:
<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="SilverlightApplication.App">
<Application.Resources>
<telerik:MetroTheme x:Key="Theme" IsApplicationTheme="True"/>
</Application.Resources>
</Application>
This did not work for me at first. It threw the follwoing exceptions:
{System.Collections.Generic.KeyNotFoundException: The given key was
not present in the dictionary. at
System.Collections.Generic.Dictionary`2.get_Item(TKey key) at
System.Windows.ResourceManagerWrapper.GetResourceForUri(Uri xamlUri,
Type componentType)}
Set property 'Telerik.Windows.Controls.Theme.ApplicationThemeSetter'
threw an exception. [Line: 53 Position: 70]
I tried declaring it in the App.xaml and the Generic.xaml but the same result.
I also tried to set the theme in the XAML like:
<t:RadGridView t:StyleManager.Theme="Windows8Theme" ..../>
But this has no affect.
NOTE: I'm using 2012's Q3
I solved the problem eventually. You have to include the theme DLL. So in my case I wanted to use the Windows8Theme, I needed to add a reference to the Telerik.Windows.Themes.Windows8.dll. It would be helpful if Telerik's code throw an exception saying as much, but "hey", that's just me.
Rashad

Resources