Why can't I find DataTemplates in merged resource dictionaries?
Posted
by dthrasher
on Stack Overflow
See other posts from Stack Overflow
or by dthrasher
Published on 2010-05-09T19:32:31Z
Indexed on
2010/05/09
19:38 UTC
Read the original article
Hit count: 254
wpf
|datatemplate
In my MainWindow.xaml, I have the following reference to a ResourceDictionary:
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="MainSkin.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
In MainSkin.xaml, I define a datatemplate:
<DataTemplate x:Key="TagTemplate">
...
</DataTemplate>
Deeper within my application, I attempt to use this data template:
<ContentControl DataContext="{Binding Tag}" ContentTemplate="{StaticResource TagTemplate}"/>
The code compiles successfully, but when I attempt to load a Page or UserControl that contains this StaticResource, I get an exception saying that the TagTemplate can't be found.
What am I doing wrong?
© Stack Overflow or respective owner