2014-12-29 4 views
1

저는 Windows Phone 8/8.1 C#/XAML .NET 4.5 응용 프로그램으로 방향을 변경하는 방법을 알고 싶습니다. 페이지에서 하나의 컨트롤/항목 (90도 회전).Windows Phone에서 한 구성 요소의 방향을 변경하는 방법 잠긴 방향이있는 8 페이지

나는 나의 세로 페이지에 웹 브라우저가 (즉, 그 방향에 잠긴 상태로 유지)와 웹 브라우저가 가로 방향으로 할 필요가 (그리고 회전하지 않습니다).

웹 브라우저를 90도 회전하고 그대로 유지하도록 설정하려면 어떻게해야합니까?

답변

0

그래서 저는 혼자서 할 수있는 방법을 찾았습니다.

커뮤니티 위키로 답변을 올리면 나중에 올 사람은 누구나이 옵션을 편집하고 추가 할 수 있습니다.

회전 변환

옵션 중 하나는 요소를 회전하는 것입니다.

는 이것을 회전 변환 (this ANS this 질문에서 결합 않음)에 의해 수행된다.

그것은 뒤에 코드에서 수행 할 수 있습니다

:

//Create a transformation RotateTransform rt = new RotateTransform(); //and set the rotation angle rt.Angle = 90; //number of degrees to rotate clockwise //for counterclockwise rotation use negative number //default rotation is around top left corner of the control, //but you sometimes want to rotate around the center of the control //to do that, you need to set the RenderTransFormOrigin //of the item you're going to rotate //I did not test this approach, maybe You're going to need to use actual coordinates //so this bit is for information purposes only controlToRotate.RenderTransformOrigin = new Point(0.5,0.5); //the name of the control is controlToRotate in this instance controlToRotate.RenderTransform = rt; 

또는 XAML에서

:이 경우에 브라우저가 내 자신의 코드와 모든 것을에서 가져

  • 항목이 회전되고 할당 된 전체 위치를 차지하도록 설정됩니다.

  • 브라우저는 그리드에, 나는 그것을에 액세스 할 수 있도록 그리드의 이름은 동적으로 위치 단순히

    브라우저는 내가 데려 갈거야,이 경우에는 폭과 높이가 지정되어 있어야
  • 그렇지 않으면 자동으로 어떻게 든 설정되고 그 결과는 꽤 작습니다.

  • 수직 및 수평 정렬은 중앙으로 설정되어 결과 회전이 중앙에 오도록 설정됩니다. 그렇지 않으면 (동적 레이아웃에서)

코드 :

<Grid x:Name="ContentPanel">    
    <phone:WebBrowser x:Name="controlToRotate" 
        VerticalAlignment="Center" 
        HorizontalAlignment="Center" 
        RenderTransformOrigin=".5, .5" 
        Width="{Binding ElementName=ContentPanel, Path=ActualHeight}" 
        Height="{Binding ElementName=ContentPanel, Path=ActualWidth}"> 
    <phone:WebBrowser.RenderTransform> 
     <RotateTransform Angle="90"/> 
    </phone:WebBrowser.RenderTransform> 
    </phone:WebBrowser> 
</Grid>