From a53c02c02da6941d49d1031ea1321f7a29c839ba Mon Sep 17 00:00:00 2001 From: jkuehner Date: Tue, 6 Aug 2013 13:23:32 +0200 Subject: [PATCH] A Resource Dictionary can not only contain Objects wich a Key or Styles. For Example a DataTemplate may be in the ResourceDictionary and has no Key set and is no Style. --- .../WpfDesign.XamlDom/Project/CollectionSupport.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs index 5907fce5bd..e50ad879c8 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs @@ -68,10 +68,14 @@ namespace ICSharpCode.WpfDesign.XamlDom } else if (collectionInstance is ResourceDictionary) { object val = newElement.GetValueFor(null); object key = newElement is XamlObject ? ((XamlObject)newElement).GetXamlAttribute("Key") : null; - if (key == null) { + if (key == null || key == "") { if (val is Style) key = ((Style)val).TargetType; + else if (val is DataTemplate) + key = ((DataTemplate)val).DataType; } + if (key == null || key == "") + key = val; ((ResourceDictionary)collectionInstance).Add(key, val); } else { collectionType.InvokeMember(