WPF custom control or form inheritance problems that occur after inheritance cannot be the root of a XAML file

Source: Internet
Author: User
When we create Basewindow in WPF or want to inherit a custom UserControl, we often encounter errors such as "The root of a XAML file cannot occur after inheritance." The reason is that inheriting a class will flush out all the contents of the base class if the contents of the form are redefined:

Workaround: 1. Base class is set to inherit window or UserControl generic class file, do not create a file with XAML. or use custom controls to create their own ControlTemplate,

     

     2. Add the Oncontentchanged method to the inherited form or control, then fill in the contents of the base class form or control, and give an example:

Workaround:

WPF custom control or form inheritance problems that occur after inheritance cannot be the root of a XAML file

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.