Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PropertyGrid raises NullReferenceException if a PropertyChanged event is raised on a null value #1464

Open
ghost opened this issue Mar 21, 2019 · 7 comments

Comments

@ghost
Copy link

ghost commented Mar 21, 2019

In my model implementing INotifyPropertyChanged if I have a string property with a null value and call the setter on the property with a null value, and raise PropertyChanged then the PropertyGrid throws a NullReferenceException.

In DescriptorPropertyDefinitionBase the line if (this.Value.Equals(this.DefaultValue)) throws if this.Value is null.

I have worked around it by making my model object setter default to string.Empty in this case, but for more complex objects there may be an issue.

@ethouin
Copy link

ethouin commented Mar 22, 2019

I have a the exact same problem with nullable DateTime Property in my model object since I updated from version 3 to 3.5.

The PropertyGrid just crashes whenever a Null is put in the DatePicker cell either from code or by deleting the Date value in the UI.

Error Message:

Object reference not set to an instance of an object.

StackTrace:

at Xceed.Wpf.Toolkit.PropertyGrid.DescriptorPropertyDefinitionBase.UpdateAdvanceOptionsForItem(DependencyObject dependencyObject, DependencyPropertyDescriptor dpDescriptor, Object& tooltip)
at Xceed.Wpf.Toolkit.PropertyGrid.DescriptorPropertyDefinition.ComputeAdvancedOptionsTooltip()
at Xceed.Wpf.Toolkit.PropertyGrid.DescriptorPropertyDefinition.OnValueChanged(Object oldValue, Object newValue)
at Xceed.Wpf.Toolkit.PropertyGrid.DescriptorPropertyDefinitionBase.OnValueChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)
at System.Windows.Data.BindingExpressionBase.Invalidate(Boolean isASubPropertyChange)
at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
at System.Windows.Data.BindingExpression.ScheduleTransfer(Boolean isASubPropertyChange)
at MS.Internal.Data.ClrBindingWorker.NewValueAvailable(Boolean dependencySourcesChanged, Boolean initialValue, Boolean isASubPropertyChange)
at MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)
at MS.Internal.Data.ClrBindingWorker.OnSourcePropertyChanged(Object o, String propName)
at MS.Internal.Data.PropertyPathWorker.OnPropertyChanged(Object sender, PropertyChangedEventArgs e)
at System.Windows.WeakEventManager.ListenerList`1.DeliverEvent(Object sender, EventArgs e, Type managerType)
at System.ComponentModel.PropertyChangedEventManager.OnPropertyChanged(Object sender, PropertyChangedEventArgs args)
at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
at SQLNext.IDE.Explorer.Wpf.UserControls.Models.XpModelBase.OnPropertyChanged(PropertyChangedEventArgs e) in D:_Clients\SQLNext\TrunkMark7\SQLNext.IDE.Explorer\Wpf\UserControls\Models\XpModelBase.cs:line 233

WPF:

    <xceed:PropertyGrid
        Background="Transparent"
        x:Name="PropertyGrid" 
        Margin="-1,25,-1,-1"
        HorizontalAlignment="Stretch" 
        VerticalAlignment="Stretch"
        ShowTitle="False"
        Visibility="Visible">
    </xceed:PropertyGrid>

@ethouin
Copy link

ethouin commented Mar 22, 2019

@XceedBoucherS
Copy link
Collaborator

Hi,
These 2 issues are already fixed in the latest v3.8 version, available for free for 45 days here : https://xceed.com/xceed-toolkit-plus-for-wpf/.
You can try it to see if it fixes your issue.
Thank you

@sqlnext
Copy link

sqlnext commented Apr 2, 2019

Ok, well now we know that the open source version is not being maintained anymore.
Thanks anyways.

@XceedBoucherS
Copy link
Collaborator

Hi,
The open source version is still maintained.
It is always about 2 or 3 versions behind the commercial version, has less features, and support is not as fast as in the commercial version. Usually, when the Commercial version offers a release, the open source version also offers a release. You can see the differences here : https://github.com/xceedsoftware/wpftoolkit/wiki/Xceed-Toolkit-Plus-for-WPF

@Dirkster99
Copy link

Usually, the open source quality is not good enough for any serious usage as there are known critical issues that are fixed in a years time (or so) and there are always new critical issues creeping up in that amount of time. You can see the difference for AvalonDock's current version 3.5 at the bottom of this page:
https://github.com/Dirkster99/AvalonDock

...and you can refere to this Wiki page for older versions:
https://github.com/Dirkster99/AvalonDock/wiki/Patch-History

@groogiam
Copy link

It looks like this has been fixed as of 9/27/2019

See DescriptorPropertyDefinitionBase.cs Line 213

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants