
So im using the property grid to display some data to the user.
I am not using the DataObject feature but rather im explicitly specify each property manually in the XAML and use binding to connect it to my ViewModel.
Here is the XAML code:
<grids:PropertyGrid SortComparer="{x:Null}" >
<grids:PropertyModel Category="General"
ValueType="{x:Type system:String}"
DisplayName="Name"
Value="{Binding Source={StaticResource proxy}, Path=Value.DataContext.DisplayName,Mode=TwoWay}"/>
<!--The 'Status' property row.-->
<grids:PropertyModel Category="General"
IsLimitedToStandardValues="True"
StandardValues="{Binding Source={StaticResource proxy}, Path=Value.DataContext.EnergizationStatuses}"
StandardValuesDisplayMemberPath="DisplayName"
Value="{Binding Source={StaticResource proxy}, Path=Value.DataContext.EnergizationStatus, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
DisplayName="Status">
<!--<grids:PropertyModel.ValueTemplate>
<DataTemplate>
<ComboBox ItemsSource="{Binding Source={StaticResource proxy}, Path=Value.DataContext.EnergizationStatuses}"
DisplayMemberPath="DisplayName"
SelectedItem="{Binding Source={StaticResource proxy}, Path=Value.DataContext.EnergizationStatus, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
</DataTemplate>
</grids:PropertyModel.ValueTemplate>-->
</grids:PropertyModel>
</grids:PropertyGrid>
and my property in the VM looks like this:
''' <summary>
''' Stores the currently selected Energization Status.
''' </summary>
Private m_energizationStatus As QualifierInfo
''' <summary>
''' Gets the currently selected Energization Status.
''' </summary>
Public Property EnergizationStatus As QualifierInfo
Get
Return m_energizationStatus
End Get
Set(value As QualifierInfo)
If value Is EnergizationStatus Then
Exit Property
End If
' SOme logic here
' Call the DoRaisePropertyChanged which will also update the field.
DoRaisePropertyChanged(NameOf(EnergizationStatus))
End Set
End Property
The issue is that when i switch my selected object the EnergizationStatus property is blank and doesn't display anything. I notice by debugging that the control tries to change the value in my view-model to Nothing.
Therefore i tried to put a check to the nothing case and exist the property set. Still is blank (even though the field is not nothing).
This behavior doesn't happen if i use a combo-box.
By changing the value binding to include a delay, this gets "fixed"... The control no longer tries to push 'Nothing' to my property:
Value="{Binding Source={StaticResource proxy}, Path=Value.DataContext.EnergizationStatus, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Delay=1}"
This seems like a odd behavior and seem to be a bug (since it is not happening on a normal combobox).