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 Kornfeld Eliyahu Peter 169
1 Zoltán Zörgő 139
2 George Jonsson 135
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web01 | 2.8.141220.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