您好,我被困在让我的VisualState正常工作。我正在尝试实现的是在用户输入上设置边框颜色,所以我要做的是
VisualStateManager.GoToState(textbox, "BorderHighlight", false);序列图像板在单独的VisualStateGroup中定义
<VisualState x:Name="BorderHighlight" >
<Storyboard >
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:05"
Storyboard.TargetName="Border" Storyboard.TargetProperty="
(Border.BorderBrush).(SolidColorBrush.Color)">
...
</ColorAnimationUsingKeyFrames>
</Storyboard>
</VisualState>问题是,textbox现在不会离开可视化状态,因此不能第二次触发。所以我必须以某种方式将它切换回正常状态。我尝试向组中添加一个正常状态似乎是不允许的(只能有一个正常状态?)我还试图设置一个正常状态,就像我在第一个状态完成后设置高亮状态一样,但也不起作用。
如果有人能在这里给我指路,我将不胜感激。
发布于 2013-03-17 18:36:57
我假设您正在创建一个自定义控件。我会有这样的东西:
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="BorderStates">
<VisualState x:Name="BorderHighlight">
<Storyboard> ... </Storyboard>
</VisualState>
<VisualState x:Name="BorderNormal">
<Storyboard> ... </Storyboard>
</VisualState>
</VisualStateGroup>
...
</VisualStateManager.VisualStateGroups>然后响应控件实现中的事件,例如
protected override void OnMouseEnter(MouseEventArgs e)
{
VisualStateManager.GoToState(this, "BorderHighlight, false);
...
}
protected override void OnMouseLeave(MouseEventArgs e)
{
VisualStateManager.GoToState(this, "BorderNormal, false);
...
}https://stackoverflow.com/questions/15459646
复制相似问题