如何在xbox上更改AppBarButton的MediaPlayerElement样式?

问题描述 投票:0回答:1

enter image description here

如图所示,我想更改MediaPlayerElement的AppBarButton样式,例如:

  1. 按钮尺寸,最好是2倍。

  2. 删除默认焦点显示边框。

  3. 将按钮更改为圆形,而不是矩形。

  4. 当按钮聚焦时,更改其背景颜色。

我已遵循https://docs.microsoft.com/en-us/windows/uwp/design/controls-and-patterns/custom-transport-controls的建议,但不知所措。

enter image description here

xaml uwp media-player
1个回答
0
投票

MediaTransportControls的默认样式中,有这样的代码段:

<!-- New AppBar button style 48x48 pixels in size -->
<Style x:Key="AppBarButtonStyle" TargetType="AppBarButton" BasedOn="{StaticResource AppBarButtonRevealStyle}">
    <Setter Property="Width" Value="{ThemeResource MTCMediaButtonWidth}" />
    <Setter Property="Height" Value="{ThemeResource MTCMediaButtonHeight}" />
    <Setter Property="AllowFocusOnInteraction" Value="True" />
</Style>

如果需要圆形按钮,可以像这样修改它

<Style x:Key="AppBarButtonStyle" TargetType="AppBarButton" BasedOn="{StaticResource AppBarButtonRevealStyle}">
    <Setter Property="Width" Value="40" />
    <Setter Property="Height" Value="40" />
    <Setter Property="AllowFocusOnInteraction" Value="True" />
    <Setter Property="CornerRadius" Value="20" />
</Style>

如果需要修改更多样式,则需要创建要调整的AppBarButton样式的副本。

因为MediaTransportControls的默认样式代码非常大,所以我放入了默认样式here的代码(还包括AppBarButtonRevealStyle的代码,您可以根据需要进行修改。

最诚挚的问候。

© www.soinside.com 2019 - 2024. All rights reserved.