如何从MediaPlayer栏中删除最右边的按钮

问题描述

我的UWP应用中有一个视频播放器,我想摆脱搜索栏上的一些按钮。 这是布局:

    <MediaPlayerElement x:Name="VideoElement"
                        AreTransportControlsEnabled="True"
                        Autoplay="True">
        <MediaPlayerElement.TransportControls>
            <MediaTransportControls IsZoomButtonVisible="False" IsFullWindowButtonVisible="False" />
        </MediaPlayerElement.TransportControls>
    </MediaPlayerElement>

enter image description here

我成功删除了“全屏”和“缩放”按钮,但是我不知道如何删除此“在设备上播放”按钮。有谁知道MediaTransportControls中的哪个字段对其进行控制?

解决方法

如何从MediaPlayer栏中删除最右边的按钮

最右边的按钮是CastButton,您可以找到MediaTransportControls样式的按钮。您可以将属性Opacity="0" IsEnabled="False"设置为隐藏。

<AppBarButton x:Name='CastButton' Opacity="0" IsEnabled="False"
    Style='{StaticResource AppBarButtonStyle}'
    MediaTransportControlsHelper.DropoutOrder='11'>
    <AppBarButton.Icon>
        <FontIcon Glyph="&#xEC15;" />
    </AppBarButton.Icon>
</AppBarButton>