This project has moved and is read-only. For the latest updates, please go here.

PropertyGrid in MVVM DataTemplate Tab

Apr 12, 2012 at 5:56 PM
Edited Apr 12, 2012 at 6:32 PM

the application has multiple "pages", each with a viewmodel and a datatemplate as view.

so i've got the PropertyGrid in a datatemplate and EditorDefinitions set, and SelectedObject bound. the problem is that the SelectedObject gets set before the EditorDefinitions are set it seems, so the PropertyGrid loads the SelectedObject with default editors.

(PropertyGridUtilities.cs:149 customTypeEditors.Count > 0 is false)

 i've looked into the source code and found that the EditorDefinitionsCollection is an observablecollection but is not observed, so changes to that one do not affect the control, unless it's SelectedObject changes.

Since its databound in a datatemplate, i don't have much of a choise in setting the order of the EditorDefinitions and the SelectedObject.

So to work around this i've put a  PropertyChangedCallback on the EditorDefinitions, and made that call

 

grid.OnSelectedObjectChanged(grid.SelectedObject, grid.SelectedObject);

 

and instaid of asssigning items into the collection, i create a new collection.

            <properties:PropertyGrid>
                <properties:PropertyGrid.EditorDefinitions>
                    <properties:EditorDefinitionCollection>
...
Developer
Aug 10, 2012 at 3:57 PM

Thank you for pointing out this bug. It will be fixed in the next release, in September 2012.

Aug 22, 2012 at 4:33 PM

This issue address the problem:

http://wpftoolkit.codeplex.com/workitem/18455