wpftoolkit icon indicating copy to clipboard operation
wpftoolkit copied to clipboard

PropertyGrid Collection Editor not firing PropertyValueChanged event?

Open xceedsoftware opened this issue 8 years ago • 6 comments

BoucherS[CodePlex]
Based on discussion https://wpftoolkit.codeplex.com/discussions/544080.

Starting in v2.3, the PropertyGrid has an editor for Collections : CollectionEditor. This editor creates a CollectionControlButton, which creates a CollectionControlDialog, which uses a CollectionControl, which uses a PropertyGrid.

The PropertyGrid.PropertyValueChanged is not propagated through this chain of elements.

Starting at v2.4, the collectionControl has a new Property : PropertyGrid. It returns the PropertyGrid from the CollectionControl. Starting at v2.4, the collectionControlDialog has a new Property : CollectionControl. It returns the CollectionControl from the CollectionControlDialog.

We need to evaluate how to raise an event, accessible to user, saying a PropertyItem of the PropertyGrid has been modified. CollectionControlDialog.CollectionControl.PropertyGrid.PropertyValueChanged could be used.

xceedsoftware avatar Jul 13 '17 08:07 xceedsoftware

BoucherS[CodePlex]
We also need to find a way to raised the CollectionControl.ItemAdded event from CollectionCollection that could be available to user.

xceedsoftware avatar Jul 13 '17 08:07 xceedsoftware

Hello, is there a workaround to be notify when a collection change ?

pacificweb avatar Apr 28 '18 15:04 pacificweb

Hello? Any Updates on this?

dhuantes avatar Oct 24 '18 16:10 dhuantes

On my side I now use https://github.com/objorke/PropertyTools PropertyGrid

pacificweb avatar Oct 25 '18 23:10 pacificweb

@pacificweb Thanks! Fortunately it's now a mute point. I originally needed it because I had a class that was originally hosted by the WinForms PropertyGrid that I needed to use on a WPF Dialog. Searched around for solutions and happened on the WPF Toolkit. When I set the SelectedObject to an instance of my class everything worked correctly except for the collection which wanted to create a new instance on the first click on the CollectionControlButton. It turns out that one of the attributes of my old implementation was causing a name clash with the property name. As soon as I removed that the PropertyGridControl no longer created the new instance and was now editing the actual collection in the SelectedObject. But I still didn't have a callback mechanism. Until I realized that my collection inherited from CollectionBase which has protected virtual methods like OnInsert and OnRemove and OnClear. I implemented the INotifyPropertyChange interface and Invoke the event in the appropriate overrides so that when I create an instance of my class and set it to the SelectedObject I can also subscribe to the PropertyChangedEvent to know when it changes. Ideally there would be an event that the PropertyGrid itself would let me subscribe to but this approach works.

dhuantes avatar Oct 30 '18 01:10 dhuantes

Hi, In v4.1, the PropertyGrid.PropertyValueChanged event will be raised when a propertyItem of type IEnumerable is modified through the CollectionEditor. Thank you.

XceedBoucherS avatar Oct 16 '20 15:10 XceedBoucherS