Leo
Leo

Reputation: 267

Windows Phone 8: multiple screen resolutions

I want to do a windows phone game that supports multiple screen resolutions. I tried this Microsoft tutorial but I always get an error message in the ResolutionHelper class.

Tutorial: http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206974(v=vs.105).aspx

Error message: The name 'App' does not exist in the current context

What is wrong?

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");
      }
    }
  }
}

Upvotes: 1

Views: 1366

Answers (2)

Brian Towers
Brian Towers

Reputation: 350

Leo: "I use Visual Studio Express 2012."

There are several different flavours of Visual Studio Express 2012. You need the specific one - "Visual Studio Express 2012 for Windows Phone". Note that it will only run on Windows 8 (or 8.1).

Upvotes: 0

thalm
thalm

Reputation: 2940

Either you are missing a using clause (maybe System.Runtime or so), or App is just an abbreviation for Application. So look closer at the compiler error. And try to find the right using or replace App by Application which might work as well.

Upvotes: 2

Related Questions