1

我想做一个支持多种屏幕分辨率的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");
      }
    }
  }
}
4

2 回答 2

2

要么您缺少一个using子句(可能是 System.Runtime 左右),要么App只是Application. 所以仔细看看编译器错误。并尝试找到合适的using或替换AppApplication可能也有效的方法。

于 2013-06-16T23:45:07.063 回答
0

Leo:“我使用 Visual Studio Express 2012。”

Visual Studio Express 2012 有几种不同的风格。您需要特定的一种 - “Visual Studio Express 2012 for Windows Phone”。请注意,它只能在 Windows 8(或 8.1)上运行。

于 2013-10-30T11:02:39.530 回答