locked
Control library and application resources best practices RRS feed

  • Question

  • Hi,

      I'd like to ask the community about how to best deal with control libraries and application resources.  Here's my scenario:  I have a number of WPF controls that are reusable, and I would like these to exist in a self-contained class library.  My problem has to do with application level resources.  Since the the class library doesn't have an Application XAML file, there isn't an obvious place to place shared top-level resources.

      What I do currently is place these top level resources in a resource dictionary XAML file, and merge that in in the Application XAML file in the executable project.  Although this works at runtime, it breaks the encapsulation of the library, and tools such as Expression Blend don't know where to find the resources when editing the class library project, because they have no idea about merging these app-level resources.

      One thing I can think of is merging the app-level resources at the top of each of my control library XAML files, but I'm afraid that will result in many instances of the same objects, since each control will have a copy.  Is that indeed what would happen?  What's the best approach?

    Thanks,

     - Imad
    Tuesday, December 12, 2006 2:14 PM

All replies

  • IMHO Merging the shared resources with the control library xaml file is the right way to go.

    Sheva
    Tuesday, December 12, 2006 2:26 PM
  • I'm not sure what you mean by "control library xaml file".  Do you mean each control's XAML file?  If so, I'm a little worried about the duplication of all the resources, if that would indeed happen (my understanding is that it would).

     - Imad
    Tuesday, December 12, 2006 4:29 PM
  •  Hi Imad!

    I have encountered the same issue during developing a modular application based on the Composite WPF libraries.

    I have written some lines how I solved this issue here: http://www.codeplex.com/CompositeExtensions/Thread/View.aspx?ThreadId=42919.

    You might find it usefull.

    jbe

    Tuesday, February 10, 2009 7:34 PM