Null references in errortemplate caused by WPF at MS. Internal.Controls.TemplatedAdorner.MeasureOverride (Size constraint)

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.