好的,所以在搜索了一些之後,我找到了一個解決方案。
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();
}"
};