About visual state management in Silverlight 2 Part2

Source: Internet
Author: User
Tags silverlight

Overview

The control templates in WPF and Silverlight support the perception of the custom control, the appearance, the visual effect of the accusation, and the sense of responsiveness of the control interaction, such as the change in state of pressing the mouse on the control, the control gaining focus, and so on. Microsoft introduced a new concept visual state Manager in Silverlight 2 Beta 2, providing a great convenience for us to create interactive control templates. Next I'll use a few articles to introduce the visual state management in Silverlight 2.

This article is the second installment of the series that describes how to customize the perception of a control with visual state management in Silverlight 2. In the previous article we introduced some of the basic concepts of visual state management, and here is an example of how to customize the perception of a control using visual state management, and finally the example effect we finished is as shown in the following illustration:

The examples in this article use the code in this article.

Defining a control template

We'll now define the template for the CheckBox control, the part described in the previous article, as shown in the following code:

<controltemplate targettype= "CheckBox"
<stackpanel x:name= "Root"
<!--Outerborder
<border width= "height="
<!--innerborder
<border x:name= "in Nerborder
<grid>
<!--higlight-->
<border x:name= Highlightbor Der > </border>
<!--Glow
<rectangle x:name= "Glow" opacity= "0" ></ Rectangle>
<!-checkmark graphic-->
<path x:name= "checkmark" opacity= "0" >< /path>
<!--indeterminate rect-->
<rectangle x:name= "Indeterminaterect" opacity= " 0 "></rectangle>
</grid>
</border>
</border>
<!--Cont Entpresenter
<contentpresenter/>
</stackpanel>
</controltemplate>

To reduce the code, some attributes are removed, but some of the necessary part names are given. Now that we're running, we can see that although the checkbox has a style, it doesn't have any interaction effects, such as clicking the mouse and the checkbox is not selected.

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.