PropertyGrid raises NullReferenceException if a PropertyChanged event is raised on a null value
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.
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>
Well, for those of you that need this production crash solved ASAP, you can always rollback to an earlier (although now unlisted) Nuget package version:
https://www.nuget.org/packages/Extended.Wpf.Toolkit/3.4.0/ https://www.nuget.org/packages/Extended.Wpf.Toolkit/3.3.0/ https://www.nuget.org/packages/Extended.Wpf.Toolkit/3.2.0/ https://www.nuget.org/packages/Extended.Wpf.Toolkit/3.1.0/ https://www.nuget.org/packages/Extended.Wpf.Toolkit/3.0.0/ ...
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
Ok, well now we know that the open source version is not being maintained anymore. Thanks anyways.
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
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
It looks like this has been fixed as of 9/27/2019
See DescriptorPropertyDefinitionBase.cs Line 213