如何在全屏模式UWP中显示特定控件

时间:2018-06-14 19:58:47

标签: c# xaml uwp uwp-xaml

我为UWP平台编写了一个YouTube客户端,现在我一直处于全屏模式。我已根据MediaElementseparate independent media controls编写了自己的视频播放器。

当我进入全屏时,我得到了这个

this

因此,在这种情况下,我需要以全屏模式显示整个视频播放器控件。但我不知道我应该怎么做。我已经尝试过了:

private async void fullscreen_Click(object sender, RoutedEventArgs e)
    {
        if (!fullScreen)
        {
            ApplicationView.GetForCurrentView().TryEnterFullScreenMode();
            mainPageBackup = (Window.Current.Content as Frame).Content as MainPage;
            (Window.Current.Content as Frame).Content = this;
        }
        else
        {
            ApplicationView.GetForCurrentView().ExitFullScreenMode();
            (Window.Current.Content as Frame).Content = mainPageBackup;
        }
    }

2 个答案:

答案 0 :(得分:1)

IsFullWindow属性设置为true;

private void OnFullScreenButtonClick(object sender, EventArgs e)
{
    videoSource.IsFullWindow = true;
}

答案 1 :(得分:0)

实际上,有一个简单的解决方案。感谢Alamakanambra的评论(在问题下方)。当我进入全屏模式时,我只是隐藏了所有不需要的东西。 我创建了一个活动,并订阅了MainPageVideoPage

public event EventHandler SetFullscreen;

private async void fullscreen_Click(object sender, RoutedEventArgs e)
{
    SetFullscreen.Invoke(this, null);
    if (!fullScreen)
    {
        ApplicationView.GetForCurrentView().TryEnterFullScreenMode();
        mainPageBackup = (Window.Current.Content as Frame).Content as MainPage;
        (Window.Current.Content as Frame).Content = this;
    }
    else
    {
        ApplicationView.GetForCurrentView().ExitFullScreenMode();
        (Window.Current.Content as Frame).Content = mainPageBackup;
    }
}
相关问题