您的位置:首页 > 移动开发

WinStoreApp8.1应用如何判断当前ViewState

2014-03-24 21:12 134 查看
 /* 测试环境: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");
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: