2010-05-05 97 views

回答

1

只需在最顶端的面板上应用RotateTransform(我认为您甚至可以在实际表面窗口上执行此操作),但角度为180度。

<s:SurfaceWindow x:Class="SurfaceApplication1.SurfaceWindow1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:s="http://schemas.microsoft.com/surface/2008" 
    Title="SurfaceApplication1"> 
    <Grid> 
    <Grid.LayoutTransform> 
     <RotateTransform x:Name="mainOrientation"/> 
    </Grid.LayoutTransform> 
    <s:SurfaceButton Click="btn_Click" Content="Click to rotate" /> 
    ... other content here ... 
    </Grid> 
</s:SurfaceWindow> 

而且在后面的代码:

private void btn_Click (object sender, RoutedEventArgs e) 
{ 
    if (mainOrientation.Angle == 0) 
     mainOrientation.Angle = 180; 
    else 
     mainOrientation.Angle = 0; 
} 

作为一个相关的话题,你还可以收听到曲面的OrientationChanged event知道,当用户更改您的应用程序的一面。一个好的做法是在发生这种情况时将应用翻转到正确的一面。

+0

@Isak,太棒了!非常感谢答案! – gyurisc 2010-05-05 17:20:34

相关问题