我将在以下实例中解释我要做什么:
我有两个页面 - MainPage.xaml(方向 Portrait)和 LandscapeLeft.xaml(方向 LandscapeLeft)。
我想从MainPage.xaml
to LandscapeLeft.xaml
当用户将手机旋转到横向位置时。
我做了如下:
XAML:
SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
后面的代码:
protected override void OnOrientationChanged(OrientationChangedEventArgs e)
{
switch (e.Orientation)
{
case PageOrientation.LandscapeLeft:
NavigationService.Navigate(new Uri("/LandscapeLeft.xaml", UriKind.RelativeOrAbsolute));
break;
}
base.OnOrientationChanged(e);
}
当我将手机从 PortraitUp 旋转到 LandscapeLeft 位置时,会发生什么:
首先,MainPage.xaml 的内容横向旋转,然后 LandscapeLeft.xaml 加载。
我想要做的是消除 MainPage.xaml 的内容轮换过程。看起来不太好,而且影响性能。简而言之,当我旋转手机时,我希望加载 LandscapeLeft.xaml
之前没有更改 MainPage.xaml 的内容方向。
请问,有什么建议吗?
将您的内容放入框架中怎么样?
当方向事件触发时,更改框架内容而不是导航到不同的页面。
...
case PageOrientation.LandscapeLeft:
FrmContents= new LandscapeLeft();
...
这应该可以解决您的性能问题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)