2013-03-25 50 views
5

我有以下問題:的Windows 8 Store應用平滑的取向變化

當我改變我的C#+ XAML頁面方向從橫向到縱向或反之亦然是有半秒左右,其中,在佈局重新計算和重新渲染之前,用戶可以在屏幕上看到大的藍色部分。這些斑點看起來像來自以前定向狀態的剩菜。

我正在尋找一種方法來隱藏或平滑這種極其粗糙和顛簸的過渡。

我試着用ProgressRing添加一個方向改變處理程序來覆蓋它1秒,但它沒有幫助 - 處理程序在藍色點後執行。 這裏是我的動畫故事板代碼

<!-- The entire page respects the narrower 100-pixel margin convention for portrait --> 
      <VisualState x:Name="FullScreenPortrait"> 
       <Storyboard> 
        <!-- Change the back button and the logo --> 
        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style"> 
         <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/> 
        </ObjectAnimationUsingKeyFrames> 
        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="headerLogoImage" Storyboard.TargetProperty="Width"> 
         <DiscreteObjectKeyFrame KeyTime="0" Value="430"/> 
        </ObjectAnimationUsingKeyFrames> 
        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="headerLogoImage" Storyboard.TargetProperty="Height"> 
         <DiscreteObjectKeyFrame KeyTime="0" Value="49"/> 
        </ObjectAnimationUsingKeyFrames> 

        <!--Change section title and navButtons to be in two rows, by moving navButtons to the second row, first column--> 
        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="navButtons" Storyboard.TargetProperty="(Grid.Row)"> 
         <DiscreteObjectKeyFrame KeyTime="0" Value="1"/> 
        </ObjectAnimationUsingKeyFrames> 
        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="navButtons" Storyboard.TargetProperty="(Grid.Column)"> 
         <DiscreteObjectKeyFrame KeyTime="0" Value="0"/> 
        </ObjectAnimationUsingKeyFrames> 
        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="navButtons" Storyboard.TargetProperty="(Grid.ColumnSpan)"> 
         <DiscreteObjectKeyFrame KeyTime="0" Value="2"/> 
        </ObjectAnimationUsingKeyFrames> 
        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="navButtons" Storyboard.TargetProperty="Margin"> 
         <DiscreteObjectKeyFrame KeyTime="0" Value="0,15,0,0"/> 
        </ObjectAnimationUsingKeyFrames> 

        <!--Change the grid--> 
        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemGridView" Storyboard.TargetProperty="Visibility"> 
         <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/> 
        </ObjectAnimationUsingKeyFrames> 
        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemPortraitGridView" Storyboard.TargetProperty="Visibility"> 
         <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/> 
        </ObjectAnimationUsingKeyFrames> 
       </Storyboard> 
      </VisualState> 

任何幫助表示感謝,謝謝!

編輯: 我解決了這個通過使用下面的方法(和我的同事的幫助下):

/// <summary> 
    /// On Orientation change collapse all views, and make visible only the views for the particular new orientation 
    /// Also change the font size for portrait mode 
    /// </summary> 
    /// <param name="sender"></param> 
    private async void OnOrientationChanged(object sender) 
    { 
     headerGrid.Visibility = Visibility.Collapsed; 
     itemGridView.Visibility = Visibility.Collapsed; 
     itemPortraitGridView.Visibility = Visibility.Collapsed; 
     itemListView.Visibility = Visibility.Collapsed; 

     //Make the loading spinner temporarily visible and stop it in the StoryBoard animation for every orientation separately 
     LoadingView.Visibility = Visibility.Visible; 

     //Change the font size 
     if (ScreenHelper.IsInPortraitMode()) 
     { 
      _viewModel.FontSizeMethod = _viewModel.GetPortraitFontSize; 
     } 
     else 
     { 
      //change font size method back 
      _viewModel.FontSizeMethod = _viewModel.GetLandscapeFontSize; 
     } 

     // Change visibility back to normal in case the xaml approach failed. 
     await Task.Delay(1000); 

     if (ScreenHelper.IsInPortraitMode()) 
      itemPortraitGridView.Visibility = Windows.UI.Xaml.Visibility.Visible; 
     else if (ApplicationView.Value == ApplicationViewState.Snapped) 
      itemListView.Visibility = Windows.UI.Xaml.Visibility.Visible; 
     else 
      itemGridView.Visibility = Windows.UI.Xaml.Visibility.Visible; 

     headerGrid.Visibility = Visibility.Visible; 
     LoadingView.Visibility = Visibility.Collapsed; 
    } 
+0

您應該將您的解決方案複製到答案中,並將其標記爲已解決。 – Tilo 2013-05-30 20:51:53

回答

0

我知道你打上這個完整的,但因爲我不能發表評論我要問在這裏。你能用這個緩解來解決嗎?

相關問題