Browse Source

Fixed so Resources are always first among child items.

pull/53/merge
gumme 12 years ago committed by Siegfried Pammer
parent
commit
270f3ad184
  1. 14
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlConstants.cs
  2. 21
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs

14
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlConstants.cs

@ -10,6 +10,8 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -10,6 +10,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
/// </summary>
public static class XamlConstants
{
#region Namespaces
/// <summary>
/// The namespace used to identify "xmlns".
/// Value: "http://www.w3.org/2000/xmlns/"
@ -27,5 +29,17 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -27,5 +29,17 @@ namespace ICSharpCode.WpfDesign.XamlDom
/// Value: "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
/// </summary>
public const string PresentationNamespace = "http://schemas.microsoft.com/winfx/2006/xaml/presentation";
#endregion
#region Common property names
/// <summary>
/// The name of the Resources property.
/// Value: "Resources"
/// </summary>
public const string ResourcesPropertyName = "Resources";
#endregion
}
}

21
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs

@ -24,6 +24,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -24,6 +24,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
CollectionElementsCollection collectionElements;
bool isCollection;
bool isResources;
static readonly IList<XamlPropertyValue> emptyCollectionElementsArray = new XamlPropertyValue[0];
@ -49,6 +50,11 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -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 @@ -116,6 +122,13 @@ namespace ICSharpCode.WpfDesign.XamlDom
set { SetPropertyValue(value); }
}
/// <summary>
/// Gets if the property represents the FrameworkElement.Resources property that holds a locally-defined resource dictionary.
/// </summary>
public bool IsResources {
get { return isResources; }
}
/// <summary>
/// Gets if the property is a collection property.
/// </summary>
@ -287,7 +300,13 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -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

Loading…
Cancel
Save