Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WPF
how to access the resource dictionary of one project in another project ? i am getting error when i am accessing the template from the resource dictionary .Tell me how to access the template of resource dictionary .give some example ?
Posted 31-Jan-13 3:45am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You can access it like (as long as Project 2 has a reference to Project 1.):
<ResourceDictionary.MergedDictionaries>
   <ResourceDictionary Source="/<YourAssemblyName>;component/<YourReferencedFileHere.xaml>" />
</ResourceDictionary.MergedDictionaries>
Similar question asked and answered here[^]
 
Read more here: MSDN: Merged Resource Dictionaries[^]
  Permalink  
Comments
kalisiddayya at 31-Jan-13 12:13pm
   
how to access the template in xaml .please tell me
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You need to know the Uri of the ResourceDictionary. You can easily use the following code to retrieve it:
private ResourceDictionary GetResourceDictionary(string assembly, string packUri)
{
  Assembly assembly = Assembly.LoadFrom(assembly);
  return dictionary = Application.LoadComponent(new Uri(packUri, UriKind.Relative)) as ResourceDictionary;
}
Then, you can call it like this:
ResourceDictionary dictionary = GetResourceDictionary("MyAssembly.dll", @"/MyAssembly;component/Resources/MyResource.xaml";
  Permalink  
Comments
kalisiddayya at 31-Jan-13 12:14pm
   
how to access the template in xaml.please inform me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,569
1 Sergey Alexandrovich Kryukov 6,168
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 31 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100