![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
Hi Rolf, I'm not sure if I fully understood your question, so please feel free to correct me if I misunderstood anything. Suppose you have a resource only class library (name it as MySharedResources), and you have a ResourceDictionary1.xaml in it: ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" SolidColorBrush x:Key="myBrush" Color="Blue"></SolidColorBrush /ResourceDictionary You can add reference to this class library in your 30 WPF assemblies and share the ResourceDictionary1.xaml: UserControl.Resources ResourceDictionary ResourceDictionary.MergedDictionaries ResourceDictionary Source="/MySharedResources;component/Dictionary1.xaml" / /ResourceDictionary.MergedDictionaries /ResourceDictionary /UserControl.Resources Grid Button Background="{StaticResource myBrush}">Hello</Button /Grid More information about the resource pack uri used to reference a resource from a referenced assembly: #Pack URIs in Windows Presentation Foundation http://msdn2.microsoft.com/en-us/library/aa970069.aspx quote The following example shows the pack URI for a XAML resource file that is located in the root folder of a referenced, version-specific assembly's project folder: pack://application:,,,/ReferencedAssembly;v1.0.0.1;component/ResourceFile.xa ml /quote Regards, Walter Wang (wawang (AT) online (DOT) microsoft.com, remove 'online.') Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. |
#4
| |||
| |||
|
#5
| |||
| |||
|
|
Hi Rolf, Please refer to following blog: #Windows Presentation Foundation SDK : Defining and Using Shared Resources in a Custom Control Library http://blogs.msdn.com/wpfsdk/archive...sing-shared-re sources-in-a-custom-control-library.aspx I've tested first approach in the blog which is using a static property to return a resource singleton and add that resource to your control's Resources.MergedDictionaries before InitializeComponent(). Although the sample code in the blog uses two controls in the same project as the resource, if you make the static property public and accessible to other assemblies, they will be able to use the same resource too. Regards, Walter Wang (wawang (AT) online (DOT) microsoft.com, remove 'online.') Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. |
#6
| |||
| |||
|
#7
| |||
| |||
|
|
Hi Rolf, Thanks for your follow-up. For first question, I think this is indeed a limitation of WPF's current implementation. I'm afraid there's no better way to workaround this issue. Please feel free to submit your feedback here http://connect.microsoft.com/Main/co...ContentID=2220. For your second question, I'm not sure if I've fully understood it. Would you please depict more? Thanks. Regards, Walter Wang (wawang (AT) online (DOT) microsoft.com, remove 'online.') Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |