Browse Source

Better fix in Collection Support for Resource Dictionarys.

They way it was now, there could be 2 Styles with the same Type and then we get the "same Key already added" Exception!
pull/52/head
jkuehner 12 years ago
parent
commit
4665be56a8
  1. 10
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs

10
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs

@ -68,12 +68,10 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -68,12 +68,10 @@ 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 || key == "") {
if (val is Style)
key = ((Style)val).TargetType;
else if (val is DataTemplate)
key = ((DataTemplate)val).DataType;
}
//if (key == null || key == "") {
// if (val is Style)
// key = ((Style)val).TargetType;
//}
if (key == null || key == "")
key = val;
((ResourceDictionary)collectionInstance).Add(key, val);

Loading…
Cancel
Save