Is this documentation still valid or am I missing something?
PropertyGrid
control does not appear to have SelectedObjects
or SelectedObjectsOverride
members. I'm using the latest version (2.5) of the Toolkit against .NET Framework 4.0.
UPDATE
@faztp12's answer got me through. For anyone else looking for a solution, follow these steps:
Bind your
PropertyGrid
'sSelectedObject
property to the first selected item. Something like this:<xctk:PropertyGrid PropertyValueChanged="PG_PropertyValueChanged" SelectedObject="{Binding SelectedObjects[0]}" />
Listen to
PropertyValueChanged
event of thePropertyGrid
and use the following code to update property value to all selected objects.private void PG_PropertyValueChanged(object sender, PropertyGrid.PropertyValueChangedEventArgs e) { var changedProperty = (PropertyItem)e.OriginalSource; foreach (var x in SelectedObjects) { //make sure that x supports this property var ProperProperty = x.GetType().GetProperty(changedProperty.PropertyDescriptor.Name); if (ProperProperty != null) { //fetch property descriptor from the actual declaring type, otherwise setter //will throw exception (happens when u have parent/child classes) var DeclaredProperty = ProperProperty.DeclaringType.GetProperty(changedProperty.PropertyDescriptor.Name); DeclaredProperty.SetValue(x, e.NewValue); } } }
Hope this helps someone down the road.