1

I'm developing an App for windows 8.1 and i need to execute a method to pause some tasks or play a sound when the app is minimized in the sidebar.

I tried:

Application.Current.Suspending += new SuspendingEventHandler(Method_Name);

private void Method_Name(object sender, object e)
{
     Other_Method();
}

But this event takes a few seconds (5~10) to occur after I minimize the app.

What event occurs when the app is dragged to the sidebar? What process sends the event?

Thanks.

seaotternerd
  • 6,298
  • 2
  • 47
  • 58

2 Answers2

1

Check out this post for the answer. It's WindowSizeChanged and check the value of ApplicationView.Value.

[EDIT]

Apparently for 8.1 things have changed a bit. The ApplicationView stuff is deprecated (that was quick) but this still takes place in SizeChanged for the window. Check out this for more details.

Community
  • 1
  • 1
Will Custode
  • 4,576
  • 3
  • 26
  • 51
  • It was one of the first things that i tried.I had used the WindowSizeChanged event to detect the state of the application (Filled, FullScreenPortrait, FullScreenLandscape and Snapped), but this event does not occur when the window is minimized in the side bar. – user3067128 Dec 04 '13 at 19:14
1

After long searching I found something that is not exactly what i wanted, but it works.

This event occurs everytime that visibility of the page changes (Is started, is maximized or minimized for exemple), then you must do some conditions using the if operator.

Window.Current.VisibilityChanged += new WindowVisibilityChangedEventHandler(One_Method);

private void One_Method(object sender, Windows.UI.Core.VisibilityChangedEventArgs e)
{
    if(Some_Condition)
    {
        //TODO: Code that you want execute.
    }
}

I'll keep the answer in open for the case of someone knows something more efficient.