Click here to Skip to main content
11,928,985 members (53,629 online)
Rate this:
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
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 Source="/<YourAssemblyName>;component/<YourReferencedFileHere.xaml>" />
Similar question asked and answered here[^]

Read more here: MSDN: Merged Resource Dictionaries[^]
kalisiddayya 31-Jan-13 12:13pm
how to access the template in xaml .please tell me
Rate this: bad
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";
kalisiddayya 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
Top Experts
Last 24hrsThis month

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