【发布时间】:2014-07-09 19:20:02
【问题描述】:
我正在尝试使用VisualStateManager 更改鼠标指针悬停在按钮上时的外观。但它不起作用。请帮忙!
XAML
<Button x:Name="button" Background="AntiqueWhite" Grid.Row="2" Grid.Column="0" MouseEnter="button_MouseEnter" MouseLeave="button_MouseLeave">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="ColorState">
<VisualState x:Name="MouseEnter">
<Storyboard Storyboard.TargetProperty="Background">
<ColorAnimation To="Aquamarine" Duration="0:1:30"/>
</Storyboard>
</VisualState>
<VisualState x:Name="MouseLeave"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Button>
С#
private void button_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
{
bool bol = VisualStateManager.GoToState(this, MouseEnter.Name, true);
}
private void button_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
{
bool bol = VisualStateManager.GoToState(this, MouseLeave.Name, true);
}
【问题讨论】:
-
你的代码在哪里?你试过什么?你有什么问题?是什么意思?你有错误吗? ...
-
对不起,代码没有立即添加。不,不会出现错误。但是 VisualStateManager.GoToState 返回 false。
-
手机上没有“鼠标指针” - 使用轻按或触摸事件?
-
有一个 MouseOver 类型的东西,你可以将手指悬停在按钮上,或者按屏幕上的其他位置然后将手指移到按钮上。
标签: c# xaml windows-phone-8 appearance