Browse Source

Cache the Instances of XamlModelProperty in a Dictionary.

This is, that we have for one Property only one Instance. With this, you can open the Flat Collection Editor, and add Columns or Rows to a Grid via the Designer, and the
List in the FlatCollectionEditor is Refreshed!
pull/58/head
jkuehner 13 years ago
parent
commit
6ca53f06c6
  1. 11
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelPropertyCollection.cs

11
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelPropertyCollection.cs

@ -4,22 +4,29 @@
using System; using System;
using System.Windows; using System.Windows;
using ICSharpCode.WpfDesign.XamlDom; using ICSharpCode.WpfDesign.XamlDom;
using System.Collections;
using System.Collections.Generic;
namespace ICSharpCode.WpfDesign.Designer.Xaml namespace ICSharpCode.WpfDesign.Designer.Xaml
{ {
sealed class XamlModelPropertyCollection : DesignItemPropertyCollection sealed class XamlModelPropertyCollection : DesignItemPropertyCollection
{ {
XamlDesignItem _item; XamlDesignItem _item;
Dictionary<string, XamlModelProperty> propertiesDictionary = new Dictionary<string, XamlModelProperty>();
public XamlModelPropertyCollection(XamlDesignItem item) public XamlModelPropertyCollection(XamlDesignItem item)
{ {
this._item = item; this._item = item;
} }
public override DesignItemProperty GetProperty(string name) public override DesignItemProperty GetProperty(string name)
{ {
return new XamlModelProperty(_item, _item.XamlObject.FindOrCreateProperty(name)); XamlModelProperty property;
if (propertiesDictionary.TryGetValue(name, out property))
return property;
property = new XamlModelProperty(_item, _item.XamlObject.FindOrCreateProperty(name));
propertiesDictionary.Add(name, property);
return property;
} }
public override DesignItemProperty GetAttachedProperty(Type ownerType, string name) public override DesignItemProperty GetAttachedProperty(Type ownerType, string name)

Loading…
Cancel
Save