'Portrait'에 해당되는 글 2건

  1. 2010.11.20 [WP7] Orientation 상태 얻기
  2. 2010.11.20 [WP7] Orientation(portrait/landscape) 설정하기
Windows Phone 7의 Orientation을 PortraitOrLandscape로 설정했다면 현재의 Orientation을 얻어오거나 Orientation이 변경되는 시점을 알아야할 때가 있습니다.

현재의 Orientation을 얻어오려면 PhoneApplicationPage.Orientation Property를 사용하면 되고, Orientation이 변경되는 시점을 알고 싶으면 PhoneApplicationPage.OrientationChanged Event를 등록해서 사용하면 됩니다.

아래는 샘플코드이고 둘다 PageOrientation enum값을 사용합니다.

public partial class MainPage : PhoneApplicationPage
{
    public MainPage()
    {
        InitializeComponent();

        //Add EventHandler
        this.OrientationChanged += new EventHandler(MainPage_OrientationChanged);
    }

    void MainPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
    {
        PageOrientation orientation = e.Orientation;
        //Check current orientation
        if ((orientation & PageOrientation.Portrait) == (PageOrientation.Portrait))
        {
            // Portrait
        }
        else
        {
            // Landscape
        }
    }

    PageOrientation GetCurrentOrientation()
    {
        return this.Orientation;
    }
}

Orientation에 대한 자세한 정보는 아래 MSDN을 참고하세요~
Posted by Gungume
,
Windows Phone 7에서는 세로모드(portrait)와 가로모드(landscape)를 지원하는데 기본적으로는 portrait모드로 설정되어있습니다.

이 Orientation은 페이지별로 설정가능하며 xaml과 Behind code에서 SupportedOrientations 값을 이용해서 설정할 수 있으며 설정될 수 있는 값은 각각 Portrait, LandscapePortraitOrLandscape입니다.

아래 코드는 각각 xaml과 Behind code(C#)를 이용해서 프로그램에서 지원할 Orientation을 설정하는 코드입니다.

//xaml
SupportedOrientations="Portrait"
SupportedOrientations="Landscape"
SupportedOrientations="PortraitOrLandscape"

//Behind code(C#)
this.SupportedOrientations = SupportedPageOrientation.Portrait;
this.SupportedOrientations = SupportedPageOrientation.Landscape;
this.SupportedOrientations = SupportedPageOrientation.PortraitOrLandscape;
Posted by Gungume
,