Property Grid - Odd behavior with Standard value - With explicit binding.

Grids for WPF Forum

Posted 5 years ago by eric
Version: 18.1.0675
Platform: .NET 4.7
Environment: Windows 10 (64-bit)
Avatar

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).

Comments (3)

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Can you put together a new simple sample project that shows this and e-mail it to our support address?   Please remove the bin/obj folders from the ZIP and rename the .zip file extension so it doesn't get spam blocked.  Then we'll debug with that and see what's going on.  Thanks!


Actipro Software Support

Posted 5 years ago by eric
Avatar

Sorry, but for the moment we have decided to stop using the property grid since we were encountering many issues with this control

(Losing binding (field becomes blank), some binding not working (but working if outside the grid, yes using the proxy command), scroll bar not scrolling properly).

We are on a tight schedule so i will not have much time to spent on putting together a sample project. 

(in our company, when someone submit an issue, we first try to replicate on our side the issue before asking the customer to provide more information or any sample projects)

Answer - Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Eric,

I'm sorry you're having trouble.  We haven't had any reports of the issues you're describing, but you are also using the PropertyGrid in a different way than most people do since you're defining the properties manually instead of setting the data via the DataObject property and letting it build up the properties.

The code you posted above is very tailored to your own app and leaves a lot out from being something we can compile.  We did try a simple example here and it worked ok for us.  So there is something more complex about your setup that is triggering the problems.  That's why we asked for a sample.

If you put it into a simple sample project with the other pieces (class definitions, etc.) needed to make it compile, we'd be able to see exactly what you see and debug with it to figure out what's happening.  Then we could either suggest changes on your end or make code changes on our end to handle it appropriately.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.