Defining different visual states for a control
You can create interactivity in your application by defining a different visual appearance for each visual state that your UserControl control, Window control, Page control, or control template can be in, and then adding behaviors or code to switch between those states based on user interaction. You can modify the transition between two state combinations, even creating animations that will run when a state is first entered.
State groups
A state group contains any visual states that are part of the same logical category, and that cannot be displayed at the same time. Only one state in a state group can be displayed at a time, but a state from one group can be displayed at the same time as a state in another state group.
For example, if you were working with a UserControl control that represented a playing card, you might have a state group named "SideDisplayed" that included states that display the card face-up (FaceUp) and face-down (FaceDown). You might also have a state group named MouseInteraction that included states that change the appearance of the card when the pointer is over the card (MouseOver), and when the card is clicked (Click). A card can be face-up and have the pointer move across it at the same time, so those states are in different state groups. However, the card cannot be face-up and face-down at the same time, so those two states can be in the same state group.
State groups and states of a playing card
For more information, see Define different visual states and transition times for a user control.
States
When you select a state, state recording is turned on, and any changes that you make will be recorded for that state. To turn off state recording, click the recording button , or select Base in the States panel. If you want to change the appearance of a state in one state group while also viewing the control in the state of another state group, you can pin a preview of the second state while in recording mode for the first state.
For more information, see Define different visual states and transition times for a user control.
To change between states, you can use the GoToStateAction behavior, or you can write code in an event handler.
For more information, see Change states in response to user interaction.
Transitions
You can extend the amount of time that it takes to transition between states when a state change occurs. You can set the transition duration for an entire state group, or for the transitions that occur between specific combinations of states.
Setting the transition duration for all states in a state group
Setting the transition duration only for transitions from the Click state to all other states
For more information, see Modify the transition time between state changes and Define different visual states and transition times for a user control.
If you want to create a smooth transition between states that modify layout properties that are discrete values (such as column or row numbers) or set automatically (such as width and height), you can use fluid layout.
For more information, see Define different visual states and transition times for a user control.
In-state animation
You can add animation to a state that will play after the control transitions to that state.
For more information, see Add animation that will play after a change in state.
Vedere anche
Attività
Create a reusable template to style a system control