0

When I load my app Property Grid looks like this:

enter image description here

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();
  • Does the class where the MyObject property is defined implement INotifyPropertyChanged? Setting the SelectedObject to null should work,. – mm8 Oct 04 '17 at 12:27
  • @mm8 Yes, it does. When I change programatically SelectedObject.WidgetObject or even SelectedObject, PropertyGrid gets updated. The only problem is with null value. – cantdoanything33 Oct 04 '17 at 12:59
  • It works fine for me. Please provide a full but minimal repo of your issue: https://stackoverflow.com/help/how-to-ask – mm8 Oct 04 '17 at 13:02
  • @mm8 Thank you for your help. I'll will put it in my post. In the meantime, could you provide the code where it works for you? – cantdoanything33 Oct 04 '17 at 13:30

0 Answers0