[英]Changing Supported Orientations
I'm writing a Windows Phone app in C#. 我正在用C#编写Windows Phone应用程序。 I have a setting
OrientationLock
that is supposed to lock the screen in portrait orientation. 我有一个设置
OrientationLock
,应该以纵向锁定屏幕。 Unfortunately, I can't for the life of me get it to work. 不幸的是,我不能为我的生活得到它的工作。 The setting saves and everything, I just can't figure out how to change the supported orientations in C#.
设置保存和一切,我只是无法弄清楚如何更改C#中支持的方向。 Here's the code I'm trying to use:
这是我正在尝试使用的代码:
public MainPage()
{
InitializeComponent();
if (AppSettings.Default.OrientationLock)
{
this.SupportedOrientations = SupportedPageOrientation.Portrait;
}
else
{
this.SupportedOrientations = SupportedPageOrientation.PortraitOrLandscape;
}
}
Thanks. 谢谢。
最终,如果从设置页面返回,则必须将代码移动到重写的OnNavigatedTo
方法(在页面类中)以更新支持的方向...构造函数仅被调用一次(如果页面未被逻辑删除)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.