我在MediaPlayerElement
中有一个Grid
,我想在调整窗口大小时将黑色背景更改为白色。我水平拉伸了MPE,所以我想更新组件颜色,而不是网格颜色。
我该怎么做?我试图更新MPE样式没有成功...
<Page x:Class="ToDelete.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page.Resources>
<Style x:Key="MediaPlayerElementStyle1" TargetType="MediaPlayerElement">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Stretch"/>
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="MediaPlayerElement">
<Grid x:Name="LayoutRoot">
<Border Background="Transparent"/>
<Image x:Name="PosterImage" Stretch="{TemplateBinding Stretch}" Source="{TemplateBinding PosterSource}" Visibility="Collapsed"/>
<MediaPlayerPresenter x:Name="MediaPlayerPresenter" IsFullWindow="{TemplateBinding IsFullWindow}" MediaPlayer="{TemplateBinding MediaPlayer}" Stretch="{TemplateBinding Stretch}"/>
<ContentPresenter x:Name="TransportControlsPresenter" Visibility="{TemplateBinding AreTransportControlsEnabled}" />
<Grid x:Name="TimedTextSourcePresenter"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Page.Resources>
<Grid Background="White">
<MediaPlayerElement x:Name="mpe"
Style="{StaticResource MediaPlayerElementStyle1}"
Source="ms-appx:///Assets/nyancat.mp4"
AreTransportControlsEnabled="False"
HorizontalAlignment="Stretch" />
</Grid>
</Page>