WPF/Windows Phone/winrt: create a unified expander Control

Source: Internet
Author: User

Effect:

WPF:

Windows 8:

Windows Phone

 

The whole process is still tortuous. in WPF, headeredcontentcontrol and expander controls are defined. Therefore, you only need to define the control template in the WPF environment.

(Expander type tree in WPF)

 

In Windows Phone and winrt environments, headeredcontentcontrol and expander controls are not available. Therefore, you must first define headeredcontentcontrol, which inherits from contentcontrol, but only adds header-related attributes, in addition to headertemplate, headertemplateselector and so on. Different frameworks also have different attributes, such as headerstringformat in WPF. winrt has unique headertransitions attributes, and Windows Phone environments support the least attributes.

 

After the headeredcontentcontrol is defined, the expander type is created to inherit from headeredcontentcontrol. Added the expander-specific attribute isexpanded. At the same time, because Windows Phone and winrt do not have a trigger, in order not to add converter in the control template definition, I added a contentvisibility attribute to the expander type in Windows Phone and winrt to change with the change of isexpanded, so that the control template can be directly bound to the definition.

 

Current versionSource codeDownload

Note: This is an archive of Microsoft SkyDrive. Please download it directly in your browser. Some download tools may not be available for download.
SourceCodeEnvironment:
WPF: Microsoft Visual Studio express 2012 for Windows Desktop
Winrt: Microsoft Visual Studio express 2012 for Windows 8
WP: Microsoft Visual Studio express 2012 for Windows Phone

Related Article

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.