Click here to Skip to main content
11,721,053 members (83,119 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 Sergey Alexandrovich Kryukov 500
1 OriginalGriff 334
2 Mika Wendelius 160
3 F-ES Sitecore 140
4 Maciej Los 80
0 Sergey Alexandrovich Kryukov 2,199
1 OriginalGriff 959
2 F-ES Sitecore 640
3 Maciej Los 609
4 Richard MacCutchan 540


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