wpftoolkit
wpftoolkit copied to clipboard
PropertyGrid when default CollectionEditor is overridden data source doesn't change
I am trying to disable properties in my PropertyGrid depending on the state of one of the CheckBoxes. eg:

When ProgramMaufacturingData is checked the properties below are enabled when unchecked the remaining properties are disabled.
I am doing this using the IsEnabled property of the PropertyGridEditorPrimitiveTypeCollectionControl:
<PropGrid:EditorTemplateDefinition TargetProperties="ManufacturerNames,TestFacilityNames"> PropGrid:EditorTemplateDefinition.EditingTemplate <DataTemplate> <toolkit:PropertyGridEditorPrimitiveTypeCollectionControl IsEnabled="{Binding DataContext.CurrentTestSuite.ProgramManufacturingData,RelativeSource={RelativeSource AncestorType=PropGrid:PropertyGrid}}" ItemsSource="{Binding Value}" /> </DataTemplate> </PropGrid:EditorTemplateDefinition.EditingTemplate> </PropGrid:EditorTemplateDefinition>
This does the job. However, I am finding that when the editor is called no changes are made to the bound data ItemsSource. I also find the same behaviour with PropertyGridEditorCollectionControl.
The problem doesn't happen if I use the default Collection Editor. So, if I comment out the above XAML and just let the PropertyGrid decide the editor then the ItemsSource data does update with the changes. Great! .. but then I can't use the IsEnabled function.
What am I missing?
I've resolved the immediate problem by using the default editor but adding a Style to the PropertyGrid resources: