Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit 50c66e0

Browse files
author
tbulle
committed
Changes to make it easier to use and customize the propertygrid from external project
1 parent c3c6584 commit 50c66e0

3 files changed

Lines changed: 24 additions & 4 deletions

File tree

src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,13 @@ public PropertyGrid()
4040

4141
Dictionary<MemberDescriptor, PropertyNode> nodeFromDescriptor = new Dictionary<MemberDescriptor, PropertyNode>();
4242

43+
public Dictionary<MemberDescriptor, PropertyNode> NodeFromDescriptor { get { return nodeFromDescriptor; } }
44+
4345
public CategoriesCollection Categories { get; private set; }
4446
public PropertyNodeCollection Events { get; private set; }
4547

48+
public EventHandler AggregatePropertiesUpdated;
49+
4650
private PropertyGridGroupMode _groupMode;
4751

4852
public PropertyGridGroupMode GroupMode
@@ -205,6 +209,8 @@ void Reload()
205209
}
206210
} finally {
207211
reloadActive = false;
212+
if (AggregatePropertiesUpdated != null)
213+
AggregatePropertiesUpdated(this, EventArgs.Empty);
208214
}
209215
}
210216

src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGridView.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,16 @@ static PropertyGridView()
2727
DefaultStyleKeyProperty.OverrideMetadata(typeof(PropertyGridView), new FrameworkPropertyMetadata(typeof(PropertyGridView)));
2828
}
2929

30+
public PropertyGridView() : this(null)
31+
{
32+
}
3033

31-
public PropertyGridView()
34+
public PropertyGridView(PropertyGrid pg)
3235
{
33-
PropertyGrid = new PropertyGrid();
36+
PropertyGrid = pg??new PropertyGrid();
3437
DataContext = PropertyGrid;
3538
}
36-
39+
3740
private Thumb thumb;
3841
public override void OnApplyTemplate()
3942
{

src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,20 @@ protected virtual DesignItem CreateItem(DesignContext context)
142142
return item;
143143
}
144144

145+
public static bool AddItemWithDefaultSize(DesignItem container, Type createdItem, Size size)
146+
{
147+
CreateComponentTool cct = new CreateComponentTool(createdItem);
148+
return AddItemWithCustomSize(container, cct.CreateItem(container.Context), new Point(0, 0), size);
149+
}
150+
145151
internal static bool AddItemWithDefaultSize(DesignItem container, DesignItem createdItem, Point position)
146152
{
147-
var size = ModelTools.GetDefaultSize(createdItem);
153+
return AddItemWithCustomSize(container, createdItem, position, ModelTools.GetDefaultSize(createdItem));
154+
}
155+
156+
internal static bool AddItemWithCustomSize(DesignItem container, DesignItem createdItem, Point position, Size size)
157+
{
158+
148159
PlacementOperation operation = PlacementOperation.TryStartInsertNewComponents(
149160
container,
150161
new DesignItem[] { createdItem },

0 commit comments

Comments
 (0)