diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlConstants.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlConstants.cs
index 95c48c552e..4ece7098f7 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlConstants.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlConstants.cs
@@ -10,6 +10,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
///
public static class XamlConstants
{
+ #region Namespaces
+
///
/// The namespace used to identify "xmlns".
/// Value: "http://www.w3.org/2000/xmlns/"
@@ -27,5 +29,17 @@ namespace ICSharpCode.WpfDesign.XamlDom
/// Value: "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
///
public const string PresentationNamespace = "http://schemas.microsoft.com/winfx/2006/xaml/presentation";
+
+ #endregion
+
+ #region Common property names
+
+ ///
+ /// The name of the Resources property.
+ /// Value: "Resources"
+ ///
+ public const string ResourcesPropertyName = "Resources";
+
+ #endregion
}
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs
index 3e2a900f07..3f5ce64d05 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs
@@ -24,6 +24,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
CollectionElementsCollection collectionElements;
bool isCollection;
+ bool isResources;
static readonly IList emptyCollectionElementsArray = new XamlPropertyValue[0];
@@ -49,6 +50,11 @@ namespace ICSharpCode.WpfDesign.XamlDom
if (propertyInfo.IsCollection) {
isCollection = true;
collectionElements = new CollectionElementsCollection(this);
+
+ if (propertyInfo.Name.Equals(XamlConstants.ResourcesPropertyName, StringComparison.Ordinal) &&
+ propertyInfo.ReturnType == typeof(ResourceDictionary)) {
+ isResources = true;
+ }
}
}
@@ -116,6 +122,13 @@ namespace ICSharpCode.WpfDesign.XamlDom
set { SetPropertyValue(value); }
}
+ ///
+ /// Gets if the property represents the FrameworkElement.Resources property that holds a locally-defined resource dictionary.
+ ///
+ public bool IsResources {
+ get { return isResources; }
+ }
+
///
/// Gets if the property is a collection property.
///
@@ -287,7 +300,13 @@ namespace ICSharpCode.WpfDesign.XamlDom
ParentObject.ElementType.Name + "." + this.PropertyName,
parentObject.OwnerDocument.GetNamespaceFor(ParentObject.ElementType)
);
- parentObject.XmlElement.AppendChild(_propertyElement);
+
+ if (this.IsResources) {
+ parentObject.XmlElement.PrependChild(_propertyElement);
+ } else {
+ parentObject.XmlElement.AppendChild(_propertyElement);
+ }
+
collection = _propertyElement;
} else {
// this is the default collection