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