简体   繁体   中英

Setting visual state group from codebehind?

Just wondering how I can switch between visual states in a visual state group, like if I have:

<SomeControl x:name="ControlName">
    <VisualStateManager.VisualStateGroups>
       <VisualStateGroup x:Name="CommonStates">
          <VisualState x:Name="Me">..</VisualState>
          <VisualState x:Name="You">..</VisualState>

And so on and so forth, how can I from codebehind set the visual state group given?

Another question I have is, if there isa control in a control, say a Canvas, can I set individual stategroups for those seperately to the parent control?

VisualStateManager.GoToState(ControlName, isMe ? "Me" : "You", true);

Some info here: VisualStateManager.GoToState Method

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM