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
/// </summary> /// </summary>
public static class XamlConstants public static class XamlConstants
{ {
#region Namespaces
/// <summary> /// <summary>
/// The namespace used to identify "xmlns". /// The namespace used to identify "xmlns".
/// Value: "http://www.w3.org/2000/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" /// Value: "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
/// </summary> /// </summary>
public const string PresentationNamespace = "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
/// <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
CollectionElementsCollection collectionElements; CollectionElementsCollection collectionElements;
bool isCollection; bool isCollection;
bool isResources;
static readonly IList<XamlPropertyValue> emptyCollectionElementsArray = new XamlPropertyValue[0]; static readonly IList<XamlPropertyValue> emptyCollectionElementsArray = new XamlPropertyValue[0];
@ -49,6 +50,11 @@ namespace ICSharpCode.WpfDesign.XamlDom
if (propertyInfo.IsCollection) { if (propertyInfo.IsCollection) {
isCollection = true; isCollection = true;
collectionElements = new CollectionElementsCollection(this); 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); } 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> /// <summary>
/// Gets if the property is a collection property. /// Gets if the property is a collection property.
/// </summary> /// </summary>
@ -287,7 +300,13 @@ namespace ICSharpCode.WpfDesign.XamlDom
ParentObject.ElementType.Name + "." + this.PropertyName, ParentObject.ElementType.Name + "." + this.PropertyName,
parentObject.OwnerDocument.GetNamespaceFor(ParentObject.ElementType) parentObject.OwnerDocument.GetNamespaceFor(ParentObject.ElementType)
); );
parentObject.XmlElement.AppendChild(_propertyElement);
if (this.IsResources) {
parentObject.XmlElement.PrependChild(_propertyElement);
} else {
parentObject.XmlElement.AppendChild(_propertyElement);
}
collection = _propertyElement; collection = _propertyElement;
} else { } else {
// this is the default collection // this is the default collection

Loading…
Cancel
Save