I have several DataTemplates in a ResourceDictionary:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:z="clr-namespace:ZoomPan">
<DataTemplate DataType="{x:Type z:Circle}">
<z:Circle Center="{Binding Center}" Radius="{Binding Radius}" x:Name="circle"/>
<DataTemplate.Triggers>
<DataTrigger ... />
</DataTemplate.Triggers>
</DataTemplate>
.... etc.
</ResourceDictionary>
I use it in a Window:
<z:MyUserControl>
<z:MyUserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Dictionary.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</z:MyUserControl.Resources>
</z:MyUserControl>
And the DataTemplates and triggers work ok.
I have two questions:
Why do DataTemplates in a ResourceDictionary not need a x:Key?
Can I divide the ResourceDictionary somehow in sections with a Key and then point to the DataTemplates in a section?