0

我有一个特殊的问题。当我将 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);
}

提前致谢。

4

1 回答 1

1

好的,修复:

case OrientationLock.VerticalLock:
                this.Dispatcher.BeginInvoke((Action)(()=>{
                this.SupportedOrientations = SupportedPageOrientation.Portrait;}));
                break;

由于某种原因,其他两种情况没有必要。如果有人有解释,我很高兴听到。

于 2013-08-15T12:07:54.637 回答