Mouseover和PointerOver VisualStates不适用于Windows 8.1中的radiobutton?

时间:2016-09-09 06:52:40

标签: windows xaml templates windows-phone-8.1 radio-button

我在Windows8.1 Phone项目中有一个单选按钮,并编辑了此radiobutton的可视状态

<RadioButton Content="wwwwwwwwwwwwwww" Style="{StaticResource HamburgerRadioButtonStyle}" GroupName="w"></RadioButton>

我使用视觉工作室混合设置了单选按钮,如下所示。但指针悬停和鼠标移动视觉状态在这里不起作用?

<Style x:Key="HamburgerRadioButtonStyle" TargetType="RadioButton">
        <Setter Property="Background" Value="{StaticResource ApplicationPaneBackgroundThemeBrush}" />
        <Setter Property="FontSize" Value="{ThemeResource TextStyleLargeFontSize}" />
        <Setter Property="FontFamily" Value="{ThemeResource PhoneFontFamilyNormal}" />
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="VerticalAlignment" Value="Top" />
        <Setter Property="Height" Value="48" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="RadioButton">
                    <Grid Background="Transparent">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames
                                                Storyboard.TargetProperty="(UIElement.Visibility)"
                                                Storyboard.TargetName="HoverBackground">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames
                                                Storyboard.TargetProperty="(UIElement.Visibility)"
                                                Storyboard.TargetName="CheckedHoverBackground">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>

                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="PointerOver">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames
                                                Storyboard.TargetProperty="(UIElement.Visibility)"
                                                Storyboard.TargetName="HoverBackground">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames
                                                Storyboard.TargetProperty="(UIElement.Visibility)"
                                                Storyboard.TargetName="CheckedHoverBackground">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>

                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <PointerDownThemeAnimation Storyboard.TargetName="Container" />
                                        <ObjectAnimationUsingKeyFrames
                                                Storyboard.TargetProperty="(UIElement.Visibility)"
                                                Storyboard.TargetName="PressedBackground">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames
                                                Storyboard.TargetProperty="(UIElement.Visibility)"
                                                Storyboard.TargetName="CheckedPressedBackground">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>

                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground"
                                                Storyboard.TargetName="ContentPresenter">
                                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="{ThemeResource ButtonDisabledForegroundThemeBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CheckStates">
                                <VisualState x:Name="Checked">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames
                                                Storyboard.TargetProperty="(UIElement.Visibility)"
                                                Storyboard.TargetName="CheckedBackground">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>

                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unchecked" />
                                <VisualState x:Name="Indeterminate" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid x:Name="Container">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="48" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Grid x:Name="NotCheckedBackground" Grid.ColumnSpan="2">
                                <Rectangle x:Name="PressedBackground" Visibility="Collapsed" Fill="#FF3C3C3C" />
                                <Rectangle x:Name="HoverBackground" Visibility="Collapsed" Fill="#474747" />
                            </Grid>
                            <Grid x:Name="CheckedBackground" Grid.ColumnSpan="2" Visibility="Collapsed"
                                    Background="#FF3C3C3C">
                                <Rectangle x:Name="CheckedPressedBackground" Visibility="Collapsed" Fill="#FF3C3C3C" />
                                <Rectangle x:Name="CheckedHoverBackground" Visibility="Collapsed" Fill="#303030" />
                            </Grid>
                            <Path  Height="38" Data="{TemplateBinding Tag}"
                                    Margin="5,8,5,5" VerticalAlignment="Center"
                                    HorizontalAlignment="Center" />
                            <ContentPresenter x:Name="ContentPresenter" AutomationProperties.AccessibilityView="Raw"
                                    ContentTemplate="{TemplateBinding ContentTemplate}"
                                    ContentTransitions="{TemplateBinding ContentTransitions}"
                                    Content="{TemplateBinding Content}" Grid.Column="1"
                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                    Margin="{TemplateBinding Padding}" 
                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

0 个答案:

没有答案