PropertyGrid.ShowPropertiesDialogCommand

Grids for WPF Forum

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

Parent
List<Child> children

[TypeConverter(typeof(ExpandableObjectConverter))]
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:


  <propgrid:PropertyGrid.CommandBindings>
                    <CommandBinding Command="{x:Static propgrid:PropertyGrid.ShowPropertyDialogCommand}" Executed="ShowPropertiesDialog" />
  </propgrid:PropertyGrid.CommandBindings>
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 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
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 8 years ago by Mary Fontana - Rudolph Technologies
Avatar
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.

Thanks.
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.