鼠标悬停的视觉状态在 WindowsPhone 上不起作用



下面是我生成按钮样式的代码。我想在鼠标悬停期间将borderbrush更改为YellowGreen,但似乎没有效果。有人能告诉我代码出了什么问题吗?这是我的密码。

    <Style x:Key="CustomButtonStyle" TargetType="Button">
        <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate>
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal">
                                    <Storyboard>
                                        <DoubleAnimation To="1" Duration="0:00:00.5" Storyboard.TargetName="NormalBackground" Storyboard.TargetProperty="Opacity"/>
                                        <DoubleAnimation To="0" Duration="0:00:00.5" Storyboard.TargetName="HoverBackground" Storyboard.TargetProperty="Opacity"/>
                                        <DoubleAnimation To="0" Duration="0:00:00.5" Storyboard.TargetName="PressedBackground" Storyboard.TargetProperty="Opacity"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation To="0" Duration="0:00:00.5" Storyboard.TargetName="NormalBackground" Storyboard.TargetProperty="Opacity"/>
                                        <DoubleAnimation To="1" Duration="0:00:00.5" Storyboard.TargetName="HoverBackground" Storyboard.TargetProperty="Opacity"/>
                                        <DoubleAnimation To="0" Duration="0:00:00.5" Storyboard.TargetName="PressedBackground" Storyboard.TargetProperty="Opacity"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimation To="0" Duration="0:00:00.5" Storyboard.TargetName="NormalBackground" Storyboard.TargetProperty="Opacity"/>
                                        <DoubleAnimation To="0" Duration="0:00:00.5" Storyboard.TargetName="HoverBackground" Storyboard.TargetProperty="Opacity"/>
                                        <DoubleAnimation To="1" Duration="0:00:00.5" Storyboard.TargetName="PressedBackground" Storyboard.TargetProperty="Opacity"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border Name="NormalBackground" CornerRadius="3" BorderBrush="Black" BorderThickness="1" Background="black" />
                        <Border Name="HoverBackground" Opacity="0" CornerRadius="3" BorderBrush="GreenYellow" BorderThickness="3" Background="Gray" />
                        <Border Name="PressedBackground" Opacity="0" CornerRadius="8" BorderBrush="Black" BorderThickness="1" Background="Red" />
                        <ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center" />
                    </Grid>
                </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

下面的代码显示了我如何在MainPage.xaml.上添加按钮

<Button x:Name="btnCall"    Click="btnCall_Click" Grid.Row="0" Grid.Column="1"  Content="test"   
Style="{StaticResource CustomButtonStyle}"   />  

Windows Phone并没有真正的鼠标悬停功能。

记住,在电话里,你没有鼠标。

[通常人们通过使用鼠标与模拟器进行交互,但手机本身当然没有类似的功能,因此支持它没有多大意义]

鼠标在未定义的区域移动光标,因此,它需要固定在地板上,以跟踪屏幕中根据创建的水平或垂直增量增加或减少的位置。

触摸屏通常被设计为在已经定义的区域中拾取和选择位置。你不会用移动鼠标"寻找"一个位置,你已经"知道"了。当你在屏幕上移动手指时,它是基于delta触发手势事件,而不是基于delta移动光标。

最新更新