??recently encountered a crash, dump information is as follows:object reference not set to a instance of an Object.At MS. Internal.Controls.TemplatedAdorner.MeasureOverride (Size constraint)
At System.Windows.FrameworkElement.MeasureCore (Size availablesize)
At System.Windows.UIElement.Measure (Size availablesize)
At System.Windows.Documents.AdornerLayer.MeasureOverride (Size constraint)
At System.Windows.FrameworkElement.MeasureCore (Size availablesize)
At System.Windows.UIElement.Measure (Size availablesize)
At System.Windows.ContextLayoutManager.UpdateLayout ()
At System.Windows.ContextLayoutMa
This information is also a problem that only the system throws, the first eye cannot locate the error. but the Templateadorner on the top of the stack gives us more information. Looking at the code, we found that we used the errortemplate, and Errortempate's display was on the Templatedadorner. You can see that Templateadorner appears under Adornerlayer when the UI's ValidationRule validation does not pass. There are several templatedadorner that have some error.
Ok, the situation should be empty when the errortemplate error pops up with an unknown reference to the object. after careful reading of the code found that there is a place to use the elements of the errortemplate, but because the later update of the data, resulting in ValidationRule passed after Errortemplate disappeared, Thus the previously quoted errortemplate will not exist.
It's easy to fix it up. If you do not have an error, you do not use errortemplate elements.
Null references in errortemplate caused by WPF at MS. Internal.Controls.TemplatedAdorner.MeasureOverride (Size constraint)