我想做一个支持多种屏幕分辨率的windows phone 游戏。我尝试了这个 Microsoft 教程,但我总是在 ResolutionHelper 类中收到错误消息。
教程: http: //msdn.microsoft.com/en-us/library/windowsphone/develop/jj206974 (v=vs.105).aspx
错误消息:当前上下文中不存在名称“App”
怎么了?
namespace WindowsPhoneGame1
{
public enum Resolutions { WVGA, WXGA, HD720p };
public static class ResolutionHelper
{
private static bool IsWvga
{
get
{
return App.Current.Host.Content.ScaleFactor == 100;
}
}
private static bool IsWxga
{
get
{
return App.Current.Host.Content.ScaleFactor == 160;
}
}
private static bool Is720p
{
get
{
return App.Current.Host.Content.ScaleFactor == 150;
}
}
public static Resolutions CurrentResolution
{
get
{
if (IsWvga) return Resolutions.WVGA;
else if (IsWxga) return Resolutions.WXGA;
else if (Is720p) return Resolutions.HD720p;
else throw new InvalidOperationException("Unknown resolution");
}
}
}
}