好的,所以在搜索了一些之后,我找到了一个解决方案。
HTML5有fullscreen api,它可用于要求全屏或退出它。您可以使用WebView的InvokeScriptAsync
方法来运行它。在我的具体情况我结束了类似下面的代码:
string[] args = {
@"if (document.exitFullscreen) {
document.exitFullscreen();
}
else if (document.msExitFullscreen) {
document.msExitFullscreen();
}"
};
await CurrentWebView.InvokeScriptAsync("eval", args);
第一句话居然是什么对我的作品,但我离开,以防万一第二个。
哦顺便说一句,如果你在BackRequested
处理程序调用InvokeScriptAsync
像我一样,你可能会想你怎么称呼它之前设置BackRequestedEventArgs.Handled
为true ,因为这是一个异步方法和事件将进一步传递到未处理的其他用户,这可能会导致不良行为。
编辑:似乎这个脚本不能在周年纪念更新(建立14393)。但是,如果您再添加一个带有webkit前缀的检查,它将起作用。像这样的东西(或者你可以留下一个带有webkit前缀的单一支票):
string[] args = {
@"if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else if(document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}"
};