如何在全屏模式 UWP 中显示特定控件 [英] How to show specific control in fullscreen mode UWP
问题描述
我为 UWP 平台编写了一个 YouTube 客户端,现在我卡在全屏模式下.我已经根据 MediaElement
和 .
I write an YouTube client for UWP platform and now I'm stuck on fullscreen mode. I've written own video player based on MediaElement
with .
当我进入全屏时,我得到了这个
And when I go to fullscreen I get this
.
所以在这种情况下,我需要以全屏模式显示整个视频播放器控件.但我不知道我应该如何做到这一点.我已经试过了:
So in that case I need to show in fullscreen mode the whole video player control. But I don't know how exactly I supposed to do this. I've already tried 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;
}
}
推荐答案
实际上有一个简单的解决方案.感谢 Alamakanambra 的评论(在问题下方).当我进入全屏模式时,我只是隐藏了我不需要的所有内容.我创建了一个事件并获得了 MainPage
和 VideoPage
订阅它.
Actually there's a one simple solution. Thanks to Alamakanambra's comment (below the question). I just hide everything that I don't need when I go to fullscreen.
I've created an event and get MainPage
and VideoPage
subscribed to it.
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;
}
}
这篇关于如何在全屏模式 UWP 中显示特定控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!