How to execute code before starting to change orientation?

1

I'm wondering if there is an event or way to run a piece of code before it happens to change orientation in Windows Phone. My problem is that I need to close a MenuFlyout before changing the orientation, otherwise the application crashes. Does anyone know how to work around this problem?

    
asked by anonymous 05.08.2015 / 19:17

1 answer

1

I do something similar. When the page orientation is changed I close a panel in my application. I do this in the triggered event when the orientation of the device changes.

public MainPage()
{
   InitializeComponent();
   this.OrientationChanged += OnOrientationChanged;
}

private void OnOrientationChanged(object sender, OrientationChangedEventArgs e)
{
   var orientação = e.Orientation;
}

Seethe here documentation

p>

EDIT

Windows Phone does not have an event with an easy-to-identify name that indicates that this event will be triggered before the screen orientation is changed, but this event exists.

The BeginLayoutChanged event fires before the orientation of the phone changes.

BeginLayoutChanged += (o, args) => MessageBox.Show("Antes de Mudar");
OrientationChanged += (o, args) => MessageBox.Show("Depois de Mudar");

More information about the event here

    
07.08.2015 / 20:43