【发布时间】:2019-09-18 22:40:29
【问题描述】:
我正在使用MediaPlayerElement,并在播放器的右上方添加了一个Image,紧随我的另一个:How to sync ui to full screen or compact mode using MediaPlayerElement。
<Image
x:Name="Image_CPLOGO" Width="160" Height="80" Margin="36"
HorizontalAlignment="Right" VerticalAlignment="Top"
Source="{TemplateBinding CPLogo}"/>
我在Customize the transport controls 之后自定义了我自己的MediaTransportControls
<MediaPlayerElement.TransportControls>
<controls:CustomMediaTransportControls
Style="{StaticResource ViuMediaTransportControls}"
x:Name="MediaTransportControls_Custom">
</controls:CustomMediaTransportControls>
</MediaPlayerElement.TransportControls>
然后在CustomMediaTransportControls.cs中,我写了
public static readonly DependencyProperty CPLogoProperty = DependencyProperty.Register("CPLogo", typeof(ImageSource),
typeof(CustomMediaTransportControls), new PropertyMetadata(null));
public ImageSource CPLogo
{
get { return (ImageSource)GetValue(CPLogoProperty); }
set { SetValue(CPLogoProperty, value); }
}
最后,我写了设置Image的代码:
MediaTransportControls_Custom.CPLogo = new BitmapImage(new Uri("https://www.gravatar.com/avatar/ccd4648ac12e04ad93a5c3a32911383a?s=64&d=identicon&r=PG"));
但这不起作用,为什么?
【问题讨论】:
标签: c# uwp media-player uwp-xaml