WPF PropertyGrid支持多种选择

这个文档是否仍然有效或者我遗漏了什么?

http://doc.xceedsoft.com/products/XceedWpfToolkit/Xceed.Wpf.Toolkit~Xceed.Wpf.Toolkit.PropertyGrid.PropertyGrid~SelectedObjects.html

PropertyGrid控件似乎没有SelectedObjectsSelectedObjectsOverride成员。 我正在使用针对.NET Framework 4.0的Toolkit的最新版本(2.5)。

UPDATE

@ faztp12的回答让我了解了。 对于寻找解决方案的其他人,请按照下列步骤操作:

  1. PropertyGridSelectedObject属性绑定到第一个选定的项目。 像这样的东西:

      
  2. 侦听PropertyValueChanged事件,并使用以下代码将属性值更新为所有选定对象。

     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); } } } 

希望这可以帮助有人在路上。

当我遇到类似的问题时,我做了什么,我订阅了PropertyValueChanged并让List填充了SelectedObjects

我检查了List的内容是否属于同一类型,然后如果是这样,我更改了每个项目中的属性:

 PropertyItem changedProperty = (PropertyItem)e.OriginalSource; PropertyInfo t = typeof(myClass).GetProperty(changedProperty.PropertyDescriptor.Name); if (t != null) { foreach (myClass x in SelectedItems) t.SetValue(x, e.NewValue); } 

我用这个是因为我需要制作一个布局设计师,这使我能够一起改变多个项目的属性:)

希望它有帮助:)

Ref Xceed Docs