Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. DataTemplate "library"

DataTemplate "library"

Scheduled Pinned Locked Moved WPF
csharpwpfdesign
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Spaz80
    wrote on last edited by
    #1

    Hello Im building an application using WPF and was wondering what was the best practise when storing my WPF DataTemplates. I want to be able to use the datatemplates on the different UI projects. Im trying to avoid the situation that all the developers have their own DataTemplates. If one developer has created a DataTemplate for an object, this shall be used. Need idees on how this is best solved Cheers Spaz

    G J 2 Replies Last reply
    0
    • S Spaz80

      Hello Im building an application using WPF and was wondering what was the best practise when storing my WPF DataTemplates. I want to be able to use the datatemplates on the different UI projects. Im trying to avoid the situation that all the developers have their own DataTemplates. If one developer has created a DataTemplate for an object, this shall be used. Need idees on how this is best solved Cheers Spaz

      G Offline
      G Offline
      Gideon Engelberth
      wrote on last edited by
      #2

      It sounds like you would be best off putting the DataTemplates in a class library and referencing that dll from every project that should use the shared templates. Once you do that, you can reference the templates like this:

      <Application.Resources>
      <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
      <ResourceDictionary
      Source="pack://application:,,,/(name of dll without extension);component/DefaultStyles.xaml" />
      </ResourceDictionary.MergedDictionaries>
      </ResourceDictionary>
      </Application.Resources>

      Notice that the resources in your external dll are broken down by file. So if you have different groups of templates or styles or whatever resources, this allows you to reference only the resources you want.

      1 Reply Last reply
      0
      • S Spaz80

        Hello Im building an application using WPF and was wondering what was the best practise when storing my WPF DataTemplates. I want to be able to use the datatemplates on the different UI projects. Im trying to avoid the situation that all the developers have their own DataTemplates. If one developer has created a DataTemplate for an object, this shall be used. Need idees on how this is best solved Cheers Spaz

        J Offline
        J Offline
        Jammer 0
        wrote on last edited by
        #3

        A nice solution to this might be to have a library of user controls in a reference central dll. I did this article on the topic the other day. http://www.codeproject.com/KB/WPF/UserControlAsDataTemplate.aspx[^]

        Jammer Going where everyone here has gone before! :) My Blog | Article(s)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups