Windows phone 7 如何在Windows phone 7上使用屏幕方向显示文本?

Windows phone 7 如何在Windows phone 7上使用屏幕方向显示文本?,windows-phone-7,windows-phone-7.1,screen-orientation,Windows Phone 7,Windows Phone 7.1,Screen Orientation,我正在学习如何使用支持的方向来更改文本块中的值或文本。我想要的是,当设备倾斜到横向模式时,文本块应该显示“Bye”,当它倾斜到纵向模式时,应该显示“Welcome” 我想知道在if()语句中应该使用哪些关系运算符,以便它提供正确的输出 我应该在if()中使用什么 if(Orientation.Equals(SupportedOrientation.grait)){//display“Welcome”} if(SupportedOrientation.Equals(SupportedPageOri

我正在学习如何使用支持的方向来更改文本块中的值或文本。我想要的是,当设备倾斜到横向模式时,文本块应该显示“Bye”,当它倾斜到纵向模式时,应该显示“Welcome”

我想知道在if()语句中应该使用哪些关系运算符,以便它提供正确的输出

我应该在if()中使用什么

  • if(Orientation.Equals(SupportedOrientation.grait)){//display“Welcome”}
  • if(SupportedOrientation.Equals(SupportedPageOrientation.肖像)){//显示“欢迎”}

  • 如何使用orientation来更改所需的任何值?

    如果要在page类中编写代码,可以使用PhoneApplicationPage类的OrientationChanged事件,也可以重写OnOrientationChanged方法

    this.OrientationChanged += new EventHandler<OrientationChangedEventArgs>(MainPage_Orientationchanged)
    
    void MainPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
    
      {
         if (orientation == PageOrientation.LandscapeLeft ||
         orientation == PageOrientation.LandscapeRight)
    
      {
    
        textblock.text = bye;
    
      }
    
    if (orientation == PageOrientation.PortraitLeft ||
         orientation == PageOrientation.PortraitRight)
    
    {
    
        textblock.text = welcome;
    }
    
     }
    
    this.OrientationChanged+=新事件处理程序(MainPage\u OrientationChanged)
    void主页面\u方向已更改(对象发送方,方向更改Deventargs e)
    {
    如果(方向==PageOrientation.LandscapeLeft||
    方向==PageOrientation.LandscapeRight)
    {
    textblock.text=bye;
    }
    如果(方向==PageOrientation.left)||
    方向==PageOrientation.right)
    {
    textblock.text=欢迎;
    }
    }
    
    谢谢!成功了。不过我还有更多的问题,我没有使用LandscapeLeft和LandscapeRight,而是修改了代码,好像(orientation==PageOrientation.scape),我试图执行,但没有成功!为什么不起作用?“横向”不包括横向左侧和右侧吗?事件仅在您将方向更改为横向左侧或右侧后激发。如果您向左转弯,则事件检查横向方向是否在左侧或右侧发生,因为这是方向控件的默认行为。如果你只是简单地提到横向,那么方向控制无法找到移动是从右还是从左,这就是为什么它不起作用。如果在我们的页面中使用许多ui控件,我们应该对左右横向进行不同的控制对齐,因此必须检查左右