简体   繁体   English

从代码隐藏设置视觉 state 组?

[英]Setting visual state group from codebehind?

Just wondering how I can switch between visual states in a visual state group, like if I have:只是想知道如何在视觉 state 组中切换视觉状态,就像我有:

<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?依此类推,我如何从代码隐藏中设置给定的可视 state 组?

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?我的另一个问题是,如果控件中有一个控件,例如 Canvas,我可以将单独的状态组分别设置为父控件吗?

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

Some info here: VisualStateManager.GoToState Method这里有一些信息: VisualStateManager.GoToState 方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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