When I load my app Property Grid looks like this:
Initially no item is selected. After I Select an item, it shows every property properly.
The thing is that I need to reload my list of items, reset the selection and set Property Grid to its initial state.
The problem: Property Grid does not go back to its initial state after having SelectedObject set to null.
Also every property has its own editor. Maybe the problem is the Instancing I am using in Bindings?
Sample Code for Property Grid:
<xctk:PropertyGrid x:Name="_propertyGrid" SelectedObject="{Binding SelectedItem.MyObject}" AutoGenerateProperties="False">
<xctk:PropertyGrid.EditorDefinitions>
<xctk:EditorTemplateDefinition TargetProperties="SampleProperty">
<xctk:EditorTemplateDefinition.EditingTemplate>
<DataTemplate>
<TextBlock Text="{Binding Instance.SampleProperty, UpdateSourceTrigger=PropertyChanged}" />
</DataTemplate>
</xctk:EditorTemplateDefinition.EditingTemplate>
</xctk:EditorTemplateDefinition>
</xctk:PropertyGrid.EditorDefinitions>
<xctk:PropertyGrid.PropertyDefinitions>
<xctk:PropertyDefinition TargetProperties="SampleProperty"/>
</xctk:PropertyGrid.PropertyDefinitions>
</xctk:PropertyGrid>
Ways I tried to reset Property Grid:
_propertyGrid.SelectedObject = null;
if (SelectedItem != null)
SelectedItem.MyObject = null;
SelectedItem = null;
_propertyGrid.Update();