我試圖改變按鈕的外觀,當鼠標指針在它上面使用VisualStateManager
。但它不起作用。請幫助!Windows Phone 8中的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。 –
手機上沒有「鼠標指針」 - 使用輕敲或觸摸事件? –