Grids for WPF Forum

Posted 9 years ago by Mary Fontana - Rudolph Technologies
I am using propgrid to display a parent object and its collection of child objects.
Something like this:

List<Child> children

class Child
[Editor(typeof(DialogTextBoxPropertyEditor), typeof(PropertyEditor))]
string Item {get; set; } // has the onPropertyChanged stuff here too

The the property Item on each child object I need to have a popup dialog that will ask for selection of a new value.
How do I set the child objects value once I get the new value in my ShowPropertiesDialog event handler?

In my property grid I define:

                    <CommandBinding Command="{x:Static propgrid:PropertyGrid.ShowPropertyDialogCommand}" Executed="ShowPropertiesDialog" />
My event handler ShowPropertiesDialog

private void ShowPropertiesDialog(object sender, ExecutedRoutedEventArgs e)
            var pgitem = e.Parameter as PropertyGridDataAccessorItem;
            if (pgitem == null) return;
            var currentItem = pgitem.Value as String;
                var dialog = new ItemSelectionDialog(currentItem);
                dialog.Comments = "Select a new owner.";
                if (dialog.ShowDialog() == true)
                    string newValue = dialog.SelectedItem;
                    pgitem.Value = newValue;
                    // how do I set the the correct childObject.Item= newValue

In above code. If I set pgitem.Value it will update the property grid display, but it does not execute the childObject's Item property.

Comments (2)

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

You should be able to set the Value property, that's what we do in our Property Editors QuickStart. If you can please put together a small sample project that reproduces your issue and email it over then we can take a closer look. Be sure to remove any executables or change the extension of the zip file to ensure it gets past our email filters.

Actipro Software Support

Posted 9 years ago by Mary Fontana - Rudolph Technologies
I fixed the problem. I was using [ReadOnly(True)] on the property.
I did this so that the property value field was read only, and wanted to use the popup dialog button instead. I fixed the problem with a custom editor.

The latest build of this product (v2020.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.