如图所示,我想更改MediaPlayerElement
的AppBarButton样式,例如:
按钮尺寸,最好是2倍。
删除默认焦点显示边框。
将按钮更改为圆形,而不是矩形。
当按钮聚焦时,更改其背景颜色。
我已遵循https://docs.microsoft.com/en-us/windows/uwp/design/controls-and-patterns/custom-transport-controls的建议,但不知所措。
在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
的代码,您可以根据需要进行修改。
最诚挚的问候。