VSM status group for Windows Phone 7 Add button

Source: Internet
Author: User

What is VSM (visual State Manager )? You can join the two jv9 blogs:

Expression blend Chinese tutorial (11)-Visual manager Quick Start visual State Manager (VSM)

Expression blend Chinese tutorial (12)-style and template Quick Start style, template

This article describes how to add custom status groups in VSM. Why? Some people may ask this question by default.

In WPF/Silverlight, if a button is used as an example, some mutually exclusive states (that is, not occurring at the same time) are allocated to the same group. For example, both focus and unfocus are attributed to the focusstates group, if pressed, normal, disabled, and Mouseover all belong to commonstates, can the status of different groups occur simultaneously? Of course, it is certain. Because a button may be in the pressed and focus state, if we want to add this state and want it to reach this state when the button is clicked, what should we do with blend? Just follow me

Create a WP7 project, drag a button, name it btnpress, modify the content attribute to press me, right-click btnpress, and select Edit template --> edit a copy, as shown in figure

 

Name Style btnpressstyle and click OK.

 

Find the States tab (if not, click windows --> states on the menu bar) and select add state Group to add state groups.

 

Name the newly added group as focuspressstates, and select add state to add the status. Here I add two statuses: pressfocused, unpressfocused

 

When we select pressfocused, we will find a red border around the beautification Board (is it very familiar? Yes, we also have a red border when recording the animation) and change the background color to red, as shown in figure

 

Launch template editing. Can you wait to see the effect after clicking?

The result is disappointed. No matter how hard you click press me, nothing hanppened!

Wait, you will think, itCode) If you know when I got to this status, I haven't set it yet! Yes, we haven't set it yet. There are two ways to set the status here. We first implement it in encoding mode.

To make the button reach the pressfocused status when you click the button, we can use the following code in the click event:

 

Press F5 and you will find that the background color of the button is changed.

However, if you want to write such a sentence for every button in this status? Is there any simple way to implement it without coding? Yes, expression blend provides a behavior named gotostateaction, which can be used for implementation.

 

Drag gotostateaction to btnpress to set its trigger event and arrival status (before dragging, we will build the project first)

 

comment out the code in the Click Event and press F5 to run the Program , you will find the same effect as writing code.

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.