我有一个特殊的问题。当我将SupportedOrientations设置为SupportedPageOrientation.Landscape时,它会自动将方向更改为LandscapeLeft,但是当我尝试将其更改为SupportedPageOrientation.Portrait时,它将保留在LandscapeLeft中。
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
switch (Settings.OrientationLock)
{
case OrientationLock.Rotate:
this.SupportedOrientations = SupportedPageOrientation.PortraitOrLandscape;
break;
case OrientationLock.HorizontalLock:
this.SupportedOrientations = SupportedPageOrientation.Landscape;
break;
case OrientationLock.VerticalLock:
this.SupportedOrientations = SupportedPageOrientation.Portrait;
break;
}
...
base.OnNavigatedTo(e);
}
提前致谢。
答案 0 :(得分:1)
好的,修正:
case OrientationLock.VerticalLock:
this.Dispatcher.BeginInvoke((Action)(()=>{
this.SupportedOrientations = SupportedPageOrientation.Portrait;}));
break;
由于某种原因,其他两种情况没有必要。如果有人有解释,我很高兴听到。