【问题标题】:Customizing Play/Pause buttons in player framework element WP8.1在播放器框架元素 WP8.1 中自定义播放/暂停按钮
【发布时间】:2015-05-27 18:03:35
【问题描述】:

我的播放器框架(XAML WINRT、Windows Phone 8.1 应用程序)有一个小的自定义问题,我正在尝试删除播放/暂停和全屏按钮周围的圆圈:

我希望它们看起来更像这样:

我可以访问播放/暂停按钮的默认 XAML:

但是 Blend 不允许我创建元素的副本以便我可以自定义它:

你知道我能做些什么来解决这个问题吗?还是有其他解决方案可以消除播放/暂停周围的圆圈?

编辑:

为了获得第二张图片,我用 Photoshop 制作了全屏按钮以显示我想要的内容。

我已经能够找到一种解决方法来找到 Blend & Visual Studio 不想给我的 AppBarButton 的样式“TransportBarButtonStyle”。

您可以在播放器框架的 codeplex 网站上找到它: https://playerframework.codeplex.com/SourceControl/latest#Universal.Xaml.Core/Themes/Classic.xaml你需要找:

<Style x:Key="TransportBarButtonStyle" TargetType="AppBarButton">

【问题讨论】:

  • 这些按钮是如何设计的?你能显示xaml代码吗?您是否为此使用 AppBarButton 类? (模板中有圆圈)如果是这样,那为什么不使用普通的按钮类呢?

标签: c# xaml windows-phone-8.1 winrt-xaml blend


【解决方案1】:

看完codeplex,https://playerframework.codeplex.com/SourceControl/latest#Universal.Xaml.Core/Themes/Classic.xaml

我创建了一个新样式,它以 AppBarButton 为目标,其边框周围没有任何圆圈:

<Style x:Key="CircleLessTransportBarButtonStyle" TargetType="AppBarButton">
    <Setter Property="Foreground" Value="{ThemeResource AppBarItemForegroundThemeBrush}"/>
    <Setter Property="VerticalAlignment" Value="Center"/>
    <Setter Property="HorizontalAlignment" Value="Center"/>
    <Setter Property="Padding" Value="0"/>
    <Setter Property="IsCompact" Value="True"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="AppBarButton">
                <Grid x:Name="RootGrid" Background="Transparent">
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="ApplicationViewStates">
                            <VisualState x:Name="FullSize"/>
                            <VisualState x:Name="Compact"/>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="CommonStates">
                            <VisualState x:Name="Normal"/>
                            <VisualState x:Name="PointerOver">
                                <Storyboard>
                                    <!--<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="BackgroundEllipse">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarItemPointerOverBackgroundThemeBrush}"/>
                                    </ObjectAnimationUsingKeyFrames>-->
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="Content">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarItemPointerOverForegroundThemeBrush}"/>
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="Pressed">
                                <Storyboard>
                                    <!--<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Stroke" Storyboard.TargetName="OutlineEllipse">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarItemForegroundThemeBrush}"/>
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="BackgroundEllipse">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarItemForegroundThemeBrush}"/>
                                    </ObjectAnimationUsingKeyFrames>-->
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="Content">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarItemPressedForegroundThemeBrush}"/>
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="Disabled">
                                <Storyboard>
                                    <!--<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Stroke" Storyboard.TargetName="OutlineEllipse">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarItemDisabledForegroundThemeBrush}"/>
                                    </ObjectAnimationUsingKeyFrames>-->
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="Content">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarItemDisabledForegroundThemeBrush}"/>
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="FocusStates">
                            <VisualState x:Name="Focused">
                                <Storyboard>
                                    <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="FocusVisualWhite"/>
                                    <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="FocusVisualBlack"/>
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="Unfocused"/>
                            <VisualState x:Name="PointerFocused"/>
                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>
                    <Viewbox Margin="{TemplateBinding Padding}">
                        <Grid Height="40" Width="40">
                            <!--<Ellipse x:Name="BackgroundEllipse" Fill="{ThemeResource AppBarItemBackgroundThemeBrush}" UseLayoutRounding="False"/>
                            <Ellipse x:Name="OutlineEllipse" Stroke="{ThemeResource AppBarItemForegroundThemeBrush}" StrokeThickness="2" UseLayoutRounding="False"/>-->
                            <ContentPresenter x:Name="Content" AutomationProperties.AccessibilityView="Raw"
                                              Content="{TemplateBinding Icon}" 
                                              Foreground="{TemplateBinding Foreground}" 
                                              HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </Viewbox>
                    <Rectangle x:Name="FocusVisualWhite" IsHitTestVisible="False" Opacity="0" StrokeDashOffset="1.5" StrokeEndLineCap="Square" Stroke="{ThemeResource FocusVisualWhiteStrokeThemeBrush}" StrokeDashArray="1,1"/>
                    <Rectangle x:Name="FocusVisualBlack" IsHitTestVisible="False" Opacity="0" StrokeDashOffset="0.5" StrokeEndLineCap="Square" Stroke="{ThemeResource FocusVisualBlackStrokeThemeBrush}" StrokeDashArray="1,1"/>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

希望对你有帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-07
    • 2023-03-19
    • 1970-01-01
    • 1970-01-01
    • 2018-12-03
    • 1970-01-01
    相关资源
    最近更新 更多