/* 测试环境:Visual Studio 2013 With C# */
protected override void OnNavigatedTo(NavigationEventArgs e)
{
Window.Current.SizeChanged += WindowSizeChanged;
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
Window.Current.SizeChanged -= WindowSizeChanged;
}
private void WindowSizeChanged(object sender, WindowSizeChangedEventArgs e)
{
// Get window size
var WindowWidth = Window.Current.Bounds.Width;
Debug.WriteLine("App code to change layout based on window width " + WindowWidth);
// Get window orientation
ApplicationViewOrientation winOrientation = ApplicationView.GetForCurrentView().Orientation;
if (winOrientation == ApplicationViewOrientation.Landscape)
{
Debug.WriteLine("Landscape layouts");
}
else if (winOrientation == ApplicationViewOrientation.Portrait)
{
Debug.WriteLine("Portrait layouts");
}
}