locked
Change Appearance

    Question

  • Hello ,

    I am a newbie, and i am making a small game which i want to get paused whenever the app changes its view(from filled, to snapped to 320 px etc.). I have a pause method which i want to call.

    Thursday, August 21, 2014 2:23 PM

Answers

  • You could handle the SizeChanged event of the window and call your pause method in the event handler, e.g:

     public sealed partial class MainPage : Page
        {
            private Model _model;
            public MainPage()
            {
                this.InitializeComponent();
    
                Window.Current.SizeChanged += Current_SizeChanged;
     }
    
     void Current_SizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e)
            {
                Size size = e.Size;
                //call your method...
                int d = 1;
            }
    }
    
    The SizeChanged event  occurs when the window has rendered or changed its rendering size: http://msdn.microsoft.com/en-us/library/ie/windows.ui.xaml.window.sizechanged
    • Marked as answer by -ManishAnand Friday, August 22, 2014 6:24 PM
    Thursday, August 21, 2014 3:05 PM

All replies

  • You could handle the SizeChanged event of the window and call your pause method in the event handler, e.g:

     public sealed partial class MainPage : Page
        {
            private Model _model;
            public MainPage()
            {
                this.InitializeComponent();
    
                Window.Current.SizeChanged += Current_SizeChanged;
     }
    
     void Current_SizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e)
            {
                Size size = e.Size;
                //call your method...
                int d = 1;
            }
    }
    
    The SizeChanged event  occurs when the window has rendered or changed its rendering size: http://msdn.microsoft.com/en-us/library/ie/windows.ui.xaml.window.sizechanged
    • Marked as answer by -ManishAnand Friday, August 22, 2014 6:24 PM
    Thursday, August 21, 2014 3:05 PM
  • thank you sir. 
    Friday, August 22, 2014 6:24 PM