向标准传输控件添加元素 [英] Add elements to the standard transport control

查看:34
本文介绍了向标准传输控件添加元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 windows 通用应用程序的标准传输控件中添加一个选择器,以便我可以选择视频的质量.

我尝试修改定义标准控件的 xaml,但控件未生效,标准控件仍然显示.

具有标准传输控制的 MediaElement:

</MediaElement>

解决方案

既然要在标准传输控件中添加选择器,选择视频的质量,我觉得仅仅编辑模板是不够的.

<块引用>

要添加或修改传输控件的功能,您必须创建一个派生自 MediaTransportControls.

创建一个从 MediaTransportControls 派生的新类:

<块引用>

  1. 向您的项目添加一个新的类文件.
  2. 修改类代码以派生自 MediaTransportControls 类.
  3. MediaTransportControls 样式和模板复制默认样式 进入 ResourceDictionary 中你的项目.这是您修改的样式和模板.
  4. 更改TargetType 到新的自定义控件类型.
  5. 设置 自定义类的 DefaultStyleKey.
  6. 添加MediaElement 到您的 XAML 标记并向其添加自定义传输控件.

有关详细信息,请参阅创建自定义传输控件 以及官方 媒体传输控件示例GitHub.

I want to add a selector into the standard transport control of windows universal apps, so i can select the quality of a video.

I tried to modify the xaml where the standard controls are defined, but the control wasn't effected and the standard control is still dislplayed.

The MediaElement with the standard transport control:

<MediaElement AreTransportControlsEnabled="True">

</MediaElement>

解决方案

Since you want to add a selector into the standard transport control and select the quality of a video, I think only editing the template is not enough.

To add to or modify the functionality of the transport controls, you must create a new class that's derived from MediaTransportControls.

To create a new class derived from MediaTransportControls:

  1. Add a new class file to your project.
  2. Modify the class code to derive from the MediaTransportControls class.
  3. Copy the default style from MediaTransportControls styles and templates into a ResourceDictionary in your project. This is the style and template you modify.
  4. Change the TargetType of the style to the new custom control type.
  5. Set the DefaultStyleKey of your custom class.
  6. Add a MediaElement to your XAML markup and add the custom transport controls to it.

For more information, please see Create custom transport controls and also the official Media transport controls sample in GitHub.

这篇关于向标准传输控件添加元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆