I defined a class with a property of Dictionary type, and add items to this property in XAML.
Class definition:
<ContentProperty("TemplateList")> Public Class ItemTemplateCreator Inherits DataTemplateSelector Public Property TemplateList As New ItemTemplateDictionary() ' Some more stuff End Class
Public Class ItemTemplateDictionary
Inherits Dictionary(Of String, DataTemplate)End Class
If I do it this way, it works:
<ctr:ItemTemplateCreator x:Key="ItemTemplateCreator"><ctr:ItemTemplateDictionary><DataTemplate x:Key="Name" DataType="ctr:SampleItem1"><TextBlock Text="{Binding Name}" VerticalAlignment="Center"/></DataTemplate></ctr:ItemTemplateDictionary></ctr:ItemTemplateCreator>
But in this way, it does not:
<DataTemplate x:Key="NameTemplate" DataType="ctr:SampleItem1"><TextBlock Text="{Binding Name}" VerticalAlignment="Center"/></DataTemplate><ctr:ItemTemplateCreator x:Key="ItemTemplateCreator"><ctr:ItemTemplateDictionary><StaticResourceExtension x:Key="Name" ResourceKey="NameTemplate"/></ctr:ItemTemplateDictionary></ctr:ItemTemplateCreator>
Actually, it shows the right data in both Cider and Expression Blend, but when running, throws an exception:
'Missing key value on 'StaticResourceHolder' object.' Line number '15' and line position '5'.
Where line 15 is where <ctr:ItemTemplateDictionary> tag is opened.
There is no stack trace, only RewrapException.
What do I do wrong?
Mikhail