Condividi tramite


Modify the transition time between state changes

Controls look different depending on which state they are in. For example, a button changes color slightly when you move your pointer over it. "MouseOver" is one of the states of a button. You can customize the transition time between states of system controls by modifying a copy of the control's template.

The following procedure uses a button, but you can customize any system control that comes with Blend for Visual Studio 2012 or any imported custom control that inherits from the Control class.

SuggerimentoSuggerimento

You can also modify the states and transition times of user controls. For more information, see Define different visual states and transition times for a user control.

To modify the transition time between states

  1. Create a reusable template for a system control, such as the Button control JJ170614.05df1779-a68f-436b-b834-a91b7995a3ec(it-it,VS.110).png.

  2. If you are not already in the editing mode of a template, right-click a control on the artboard, point to Edit Template, and then click Edit Current. Optionally select the object, and then click Template in the breadcrumb bar.

    JJ170614.5bb586ea-6adc-4672-b316-0fab8215ff8c(it-it,VS.110).png

  3. While Blend is in template-editing mode, the states of the button (such as Normal and MouseOver) are displayed in the States panel. States are contained in state groups (such as CommonStates and FocusStates).

    JJ170614.7740762c-1a9d-490f-898e-2886ac1cf541(it-it,VS.110).png

    Next to CommonStates, you will see a text box with the value of 0 seconds ("0s"). This is the default transition duration for all the transitions between the states in the state group. For example, it takes 0 seconds to transition from any state to the Normal state. You can change this default transition duration.

    JJ170614.f13475c2-d26f-4ad0-b62e-53bd1f532288(it-it,VS.110).png

  4. Click Add transition JJ170614.2fe2c349-41aa-4cc0-b1d3-3ff7d5aed33d(it-it,VS.110).png for the MouseOver state under States, and then click the MouseOver to Normal transition.

    JJ170614.fdeff432-52c4-46c2-a3f1-6ee49d86677b(it-it,VS.110).png

  5. In the new line for the MouseOver to Normal transition, change the value in the text box from "0s" to "0.5s."

    JJ170614.ba5ad076-c4f4-4525-b8a6-ac3aab272194(it-it,VS.110).png

  6. Save your work (Ctrl+S), and then press F5 to build and test your application. After your application opens in a browser window, move your pointer over the button to see how slowly it transitions back to its previous state when the pointer moves off the button.

Troubleshooting

Next steps

Vedere anche

Attività

Draw a control in your project

Add animation that will play after a change in state

Create a reusable template to style a system control