在 FullWindows 模式下不会触发 MediaElement 的操作事件 [英] Manipulation events of MediaElement not fire when on FullWindows mode

查看:29
本文介绍了在 FullWindows 模式下不会触发 MediaElement 的操作事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将播放器设置为非全屏模式 (player.IsFullWindows = false) 时,事件正常工作,但是当将播放器更改为全屏时,所有操作事件都不起作用.有人有解决办法吗?

When I set player not in fullscreen (player.IsFullWindows = false), event work normally but when change player to full screen all manipulation event not work. Anyone have solution?

                <MediaElement Name="player"
                              Margin="10,5" ManipulationCompleted="player_ManipulationCompleted"
                              ManipulationDelta="Grid_ManipulationDelta"
                              ManipulationMode="TranslateX"
                              >

推荐答案

我可以通过启用 IsFullWindow="True"AreTransportControlsEnabled="True" 来重现这个场景强>.我认为这是有道理的,因为当我们处于全窗口模式时,它将转到名为 FullWindowMediaRoot 的新层,而不是 MediaElement.在 FullWindowMediaRoot 中,它是 MediaTransportControls.您可以通过使用 Live Visual Tree 清楚地看到这一点,如下所示:

I can reproduce this scenario by enabling both the IsFullWindow="True" and the AreTransportControlsEnabled="True". I think it makes sense, because when we are in the Full Window mode, it will go to the new layer named FullWindowMediaRoot instead of the MediaElement. Inside the FullWindowMediaRoot, it is the MediaTransportControls. You can see that clearly by using the Live Visual Tree as following:

所以当我们处于全窗口模式时,我们需要处理TransportControls的操作事件而不是MediaElement的操作事件,如下所示:

So when we are in the Full Window mode, we need to handle the manipulation event of the TransportControls instead of the manipulation event of the MediaElement as following:

public MainPage()
    {
        this.InitializeComponent();
        player.TransportControls.ManipulationMode = ManipulationModes.TranslateX;
        player.TransportControls.ManipulationDelta += TransportControls_ManipulationDelta;
        player.TransportControls.ManipulationCompleted += TransportControls_ManipulationCompleted;

    }

    private void TransportControls_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
    {

    }

    private void TransportControls_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
    {

    }

谢谢.

这篇关于在 FullWindows 模式下不会触发 MediaElement 的操作事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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