Question

PropertyEditor - access to edited property

Posted 6 years ago by Avatar Aleksander Brzozowski
Hi
I have a class:
EditableInPropertyGridClass
{
...
public MyPropertyClass MyPropertyName //MyProperty
{
... //set, get
}
}

I create property editor and add to PropertyGrid.PropertyEditors :
PropertyEditor pe = new PropertyEditor();
pe.PropertyName = "MyPropertyName";
pe.PropertyType = typeof(MyPropertyClass);
pe.ValueTemplate = MyPropertyTemplate;
propertyGrid.PropertyEditors.Add(pe);
propertyGrid.SelectedObject = new EditableInPropertyGirdClass();

MyPropertyTemplate has a button
...
<Button Grid.Column="1" Click="Button_Click" />
...

After Click a button(Button_Click) I`d like show my own window to property edit.
Question is - how can I send my property value to window?
From where I can get "MyPropertyName" value?

Thank for any suggestions

Comments (2)

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Aleksander,

The Property Editors Quick Start in the sample browser shows two examples of using dialogs from custom property editors. In essence, you need to search up the visual tree for an instance of propgrid:IPropertyDataAccessor, which provides access to the underyling property.

In your case, you could use something like:
Button button = (Button)sender;
IPropertyDataAccessor accessor = VisualTreeHelperExtended.GetAncestor(button,
    typeof(IPropertyDataAccessor)) as IPropertyDataAccessor;
// TODO: Update property using accessor.Value

Actipro Software Support
Posted 6 years ago by Aleksander Brzozowski
It works:)
Thanks a lot!!!
Information The latest build of this product (2014.1 build 0602) was released 2 months ago, which was after the last post in this thread.

Add a Comment

Please log in to a validated account to post comments.