Browse Source

Made it possible to add resources to a ResourceDictionary through DesignItemProperty.CollectionElements.

pull/53/merge
gumme 12 years ago committed by Siegfried Pammer
parent
commit
1bd00ea220
  1. 5
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs
  2. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionElementsCollection.cs
  3. 15
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs
  4. 5
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs

5
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs

@ -53,6 +53,11 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -53,6 +53,11 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
set { this.Properties["Name"].SetValue(value); }
}
public override string Key {
get { return XamlObject.GetXamlAttribute("Key"); }
set { XamlObject.SetXamlAttribute("Key", value); }
}
#if EventHandlerDebugging
static int totalEventHandlerCount;
#endif

4
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionElementsCollection.cs

@ -51,7 +51,9 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -51,7 +51,9 @@ namespace ICSharpCode.WpfDesign.XamlDom
{
XamlPropertyInfo info = property.propertyInfo;
object collection = info.GetValue(property.ParentObject.Instance);
CollectionSupport.Insert(info.ReturnType, collection, item, index);
if (!CollectionSupport.TryInsert(info.ReturnType, collection, item, index)) {
CollectionSupport.AddToCollection(info.ReturnType, collection, item);
}
item.ParentProperty = property;
property.InsertNodeInCollection(item.GetNodeForCollection(), index);

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

@ -94,6 +94,21 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -94,6 +94,21 @@ namespace ICSharpCode.WpfDesign.XamlDom
CultureInfo.InvariantCulture);
}
/// <summary>
/// Adds a value at the specified index in the collection. A return value indicates whether the Insert succeeded.
/// </summary>
/// <returns>True if the Insert succeeded, false if the collection type does not support Insert.</returns>
internal static bool TryInsert(Type collectionType, object collectionInstance, XamlPropertyValue newElement, int index)
{
try {
Insert(collectionType, collectionInstance, newElement, index);
} catch (MissingMethodException) {
return false;
}
return true;
}
static readonly Type[] RemoveAtParameters = { typeof(int) };
/// <summary>

5
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs

@ -64,6 +64,11 @@ namespace ICSharpCode.WpfDesign @@ -64,6 +64,11 @@ namespace ICSharpCode.WpfDesign
/// </summary>
public abstract string Name { get; set; }
/// <summary>
/// Gets/Sets the value of the "x:Key" attribute on the design item.
/// </summary>
public abstract string Key { get; set; }
/// <summary>
/// Is raised when the name of the design item changes.
/// </summary>

Loading…
Cancel
Save