With windows phone, is there an event I can register for when the device entered landscape mode?
The reason why I am asking this is because we have a view with an input box. And when in landscape mode, the TextBox
is partially blocked by the keyboard. So I am thinking may have to hide some additional information on the page when it is in landscape mode (for example, hide the title of the page and etc.).
The following is a simple example. Left: Before keyboard is shown; Right: After keyboard is shown.
I posted another question related to this and has a better solution as far as I am concerned:
Why isn't the TextBox inside ContentDialog automatically scroll above keyboard
But no matter what, here is the complete code for orientation change event:
// Define this in the class
private SimpleOrientationSensor _simpleorientation;
// Put hits in the Constructor
_simpleorientation = SimpleOrientationSensor.GetDefault();
if (_simpleorientation != null)
{
_simpleorientation.OrientationChanged += new TypedEventHandler<SimpleOrientationSensor, SimpleOrientationSensorOrientationChangedEventArgs>(OrientationChanged);
}
// Event function
private void OrientationChanged(object sender, SimpleOrientationSensorOrientationChangedEventArgs e)
{
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
{
// ...
});
}
Your best bet would be describing to
Windows.Current.SizeChanged
event and testing if width is more than height. There is also a sensor for this, but is is a bit problematic, take a look at http://www.jayway.com/2014/10/06/detecting-orientation-in-universal-apps-windows-phone-8-1/..xaml
.cs