Search Unity

'Window' does not contain a definition for 'Current'

Discussion in 'Windows' started by sstrong, Aug 16, 2014.

  1. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,255
    Here is the error when creating a project from Unity 4.x

    Error 5 'Window' does not contain a definition for 'Current'

    public MainPage(SplashScreen splashScreen)
    {
    this.InitializeComponent();
    splash = splashScreen;
    GetSplashBackgroundColor();
    OnResize();
    onResizeHandler = new WindowSizeChangedEventHandler((o, e) => OnResize());
    **ERROR HERE** Window.Current.SizeChanged += onResizeHandler;
    }

    And here is the fix:

    public MainPage(SplashScreen splashScreen)
    {
    this.InitializeComponent();
    splash = splashScreen;
    GetSplashBackgroundColor();
    OnResize();
    onResizeHandler = new WindowSizeChangedEventHandler((o, e) => OnResize());
    Windows.UI.Xaml.Window.Current.SizeChanged += onResizeHandler;
    }
     
  2. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Did you submit a bug report?
     
  3. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,255
    No. It may not affect all users as it will only be an issue for people that have other objects that contain "Window" in the namespace.