Merged DataTemplateDictionary

In my application I have palette diagram and main diagram. The palette show nodes that I consider to be templates of nodes in the main diagram, for example the palette will show employee, contractor, car and the main diagram will show Mr. Black which is an employee, Mr White which is a contractor and Ferrari which is a car.
I want to share the DataTemplates of the draggable nodes with both the palette and the main diagram. Opposed to the sample applications you have I don't want to have one big DataTemplateDictionary, I rather take WPF approach of having multiple manageable DataTemplateDictionary and be able to merge them together as needed. In this specific case I will have "DraggableDataTemplates" and "StandardDataTemplate", the palette will have only the DraggableDataTemplates and the main diagram will have both the StandardDataTemplates and the DraggableDataTemplates.

Thank you,
Ido.

Go ahead and define the two DataTemplateDictionarys as you have been. I assume you have been doing:

<....Resources> <go:DataTemplateDictionary x:Key="StandardDataTemplates"> <DataTemplate x:Key="..."> ... </DataTemplate> <DataTemplate x:Key="..."> ... </DataTemplate> </go:DataTemplateDictionary> <go:DataTemplateDictionary x:Key="DraggableDataTemplates"> <DataTemplate x:Key="..."> ... </DataTemplate> <DataTemplate x:Key="..."> ... </DataTemplate> </go:DataTemplateDictionary> </....Resources>
Add a third one as a resource:

    <go:DataTemplateDictionary x:Key="DiagramDataTemplates" />

Then your controls could be:

<go:Palette NodeTemplateDictionary="{StaticResource DraggableDataTemplates}" ... /> <go:Diagram NodeTemplateDictionary="{StaticResource DiagramDataTemplates}" ... />
And in code you do the “merge”:

var dtd = Diagram.FindResource<DataTemplateDictionary>(myDiagram, "DiagramDataTemplates"); foreach (var kvp in Diagram.FindResource<DataTemplateDictionary>(myDiagram, "DraggableDataTemplates")) { dtd.Add(kvp.Key, kvp.Value); } foreach (var kvp in Diagram.FindResource<DataTemplateDictionary>(myDiagram, "StandardDataTemplates")) { dtd.Add(kvp.Key, kvp.Value); }