Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

检测Windows Phone的方向

From Wiki
Jump to: navigation, search
WP Metro Icon UI.png
SignpostIcon XAML 40.png
SignpostIcon WP7 70px.png
Article Metadata

兼容于
文章
WS_YiLunLuo 在 29 Dec 2011 创建
最后由 hamishwillee 在 16 Jul 2013 编辑

简介

这篇文章给出了简单的代码来检测Windows Phone的方向(orientation)。高手们不用阅读本文。

定位

Windows Phone可以被放到两个方向,横向和纵向。为了支持windows phone方向的改变,你需要改变你自己项目中的main .xaml文件。搜寻下面这一行 phone:PhoneApplicationPage并按照下面的方式改变它的值。 SupportedOrientations="PortraitOrLandscape . 在phone上创建OrientationChanged事件并写入下面所示的代码。

private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
{
MessageBox.Show (e.Orientation.ToString()) ;
}
This page was last modified on 16 July 2013, at 07:47.
41 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×