【问题标题】:How to control customized MediaTransportControls?如何控制自定义的 MediaTransportControls?
【发布时间】: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


    【解决方案1】:

    您是否将您的CustonMediaTransportControl 应用于您的MediaTransportControls 样式?

    <Style TargetType="local:CustomMediaTransportControls">
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="FlowDirection" Value="LeftToRight" />
        <Setter Property="UseSystemFocusVisuals" Value="True" />
        <Setter Property="IsTextScaleFactorEnabled" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:CustomMediaTransportControls">
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-26
      • 1970-01-01
      • 2013-08-01
      • 2023-03-25
      • 2014-12-16
      • 1970-01-01
      • 2019-08-17
      • 1970-01-01
      相关资源
      最近更新 更多