2014-02-21 67 views
0

我正在爲Windows Phone開發應用程序。Windows Phone更改方向更改的用戶界面

它有一個視頻播放器。

現在,我想在手機方向更改時更改用戶界面。視頻播放器應該全屏顯示。

但問題是,當用戶界面發生變化時,我不希望視頻播放器暫停或停止或再次加載。

因此,在內容面板中,我製作了2個網格。

我想我會完全隱藏一個網格並將視頻播放器移動到另一個網格。 這個其他網格將是屏幕上唯一可見的東西 - 所以它會是全屏。

但是視頻播放器是在一個關鍵點內。

這裏是xaml-

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> 

     <Grid Name="VideoPlayerGrid" > 
      <Grid.RowDefinitions> 
       <RowDefinition Height="*" /> 
      </Grid.RowDefinitions> 

      //I want my video player here - this should make it full screen 
     </Grid> 

     <Grid Name="ContentGrid"> //I would hide this grid completely 

      <phone:Pivot Name="Pivot1"> 
       <phone:PivotItem Header="PivotItem1"> 
        <Grid> 
         <Grid.RowDefinitions> 
          <RowDefinition Height="Auto"/> 
          <RowDefinition Height="Auto"/> 
         </Grid.RowDefinitions> 

         // my video player is here 

        </Grid> 
       </phone:PivotItem> 

       <phone:PivotItem Header="PivotItem2"> 

       </phone:PivotItem> 
      </phone:Pivot> 

我怎樣才能處理方向變化?

回答

0

首先,在您的XAML

的頁面中添加OrientationChanged="PhoneApplicationPage_OrientationChanged"然後在處理它的代碼隱藏:

private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e) 
{ 
    if (e.Orientation == PageOrientation.Landscape || 
     e.Orientation == PageOrientation.LandscapeLeft || 
     e.Orientation == PageOrientation.LandscapeRight) 
     { 
      // do something    
     } 
     else 
     { 
      // do something    
     } 
} 
+0

克里斯·邵,TY我知道這個方法,有什麼事我需要在它裏面寫讓我的視頻播放器從一個網格到另一個網格?檢查我的xaml - 我已經寫了視頻播放器的位置和改變方向後我想要的位置 – kshitijgandhi

+0

也許你可以從舊的網格中刪除你的控制,並將它添加到你的新網格 –

+0

Chris Shao,是的,我想這樣做 - 但我該怎麼做 – kshitijgandhi