Click here to Skip to main content
11,579,093 members (74,443 online)
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 2: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 183
1 Frankie-C 115
2 Afzaal Ahmad Zeeshan 85
3 Richard Deeming 60
4 Suvendu Shekhar Giri 60
0 OriginalGriff 933
1 Sergey Alexandrovich Kryukov 740
2 Abhinav S 573
3 F-ES Sitecore 420
4 Dave Kreskowiak 419


Advertise | Privacy | Mobile
Web04 | 2.8.150603.1 | Last Updated 31 Jan 2013
Copyright © CodeProject, 1999-2015
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