Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Packaging ResourceDictionary for Silverlight Class Library

I have a silverlight class library (not a top-level application) with several user controls that are shared by different silverlight applications. I have gone through and pulled out several styles and brushes for the controls and put them in a separate XAML file as a resource dictionary which I bring into each control as a merged resource dictionary. Right now this works great in my top-level applications, as long as I keep that resource dictionary as a "Resource" build action and reference it in that way from the controls.

What I would really like to do is have this resource dictionary XAML file as a "Content" build action which gets copied into the top-level XAP, so that the XAML can be swapped out in the XAP file without needing to rebuild the project. Whenever I try to set this up, the XAML file will get copied into the output bin for the class library project, but it will never get copied to my top-level silverlight application project output directory or into the final XAP file.

What is the best way to accomplish this? The XAML resource dictionary is essentially a dependency of the class library, and the class library (of user controls) is a dependency of the top-level silverlight application.

like image 368
Dan Auclair Avatar asked Dec 18 '09 00:12

Dan Auclair


1 Answers

Add the ControlResources.xaml (the ResourceDictionary you want in your XAP) to the top-level XAP project as a link via Project->Add Existing Item->Add as Link (a drop down item on the Add button in the dialog), and set it to build as Content, also.

like image 107
Tim Erickson Avatar answered Oct 18 '22 04:10

Tim Erickson