2016-10-10 35 views
0

我想知道如何強制UWP應用程序的Windows 8.1在全屏幕模式下的Windows 10。Uwp 8.1全屏C#

ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.FullScreen; 

不適用於我,我沒有方法PreferredLaunchWindowingMode

我也嘗試過查看,但我沒有方法TryToFullScreen,正如Microsoft指南中所述。

謝謝

回答

0

據我所知,沒有API在全屏模式下獲得windows 8.1應用程序。 ApplicationView.PreferredLaunchWindowingModeApplicationView.GetForCurrentView是Windows 10 API。強烈建議將現有項目移植到Universal Windows Platform。

,但如果你真的想使用Windows 8.1的應用程序的新功能,有一個醜陋的解決方法可以訪問這些API(使用反射):

using System.Linq; 
using System.Reflection; 
... 
var view = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView(); 
var runtimeMethods = view.GetType().GetRuntimeMethods();// get the runtime methods 
var tryEnterFullScreenMode = runtimeMethods.FirstOrDefault(x => x.Name == "TryEnterFullScreenMode"); 
tryEnterFullScreenMode?.Invoke(view, null);//invoke the tryEnterFullScreenMode method. 
+0

謝謝,它很好用! –

+0

所以,這是答案[可接受的答案](http://stackoverflow.com/help/someone-answers)? –

+0

是的,這是正確的答案 –

0

你可以試試嗎?

ApplicationView.GetForCurrentView().TryEnterFullScreenMode(); 
+0

是的,但它不工作。我沒有這個方法 –