DataTemplate "library"
-
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
-
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
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.
-
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
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)