Posted 13 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:
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:My event handler ShowPropertiesDialog
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.
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>
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
}
}