RemovePropertyChildCommand

Grids for WPF Forum

Posted 8 years ago by Mary Fontana - Rudolph Technologies
Avatar
I have added a command binding for
PropertyGrid.RemovePropertyChildCommand so that I can comfirm the delete of the property child item.

<CommandBinding
Command="{x:Static propgrid:PropertyGrid.RemovePropertyChildCommand}"
Executed="RemovePropertyChild_Executed" />


In my method:
private void RemoveChildProperty_Executed(object sender, ExecutedRoutedEventArgs e)

I can see the item I want to remove in e.Parameter.Value;
But how do you remove the item from the collection holding on to it?

Or is there another way of doing this?


Thanks,
Mary

Comments (1)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Mary,

Our default handler in PropertyGrid looks like this:
protected virtual void OnRemovePropertyChild(ExecutedRoutedEventArgs e) {
    if (e == null)
        throw new ArgumentNullException("e");

    if (!this.IsReadOnly) {
        IPropertyDataAccessor propertyDataAccessor = e.Parameter as IPropertyDataAccessor;
        if (propertyDataAccessor != null && propertyDataAccessor.CanRemove) {
            e.Handled = true;
            propertyDataAccessor.Remove();
        }
    }
}
You may want to create a class that derives from PropertyGrid (i.e. MyPropertyGrid) and simply override our OnRemovePropertyChild method. Otherwise, that command will have two handlers, even if one is never called.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.