2011-04-08 21 views
1

我切換到我的應用程序,而不是通過Popup的框架使用ProgressBar/Grid內。我使用這個堆棧溢出後得到它的工作:Dynamic Progress bar In WP7幀不與進度使用工具包轉換框架模板

但是,當使用示例我不再有頁面轉換。如果頁面轉換不能正常工作,我很難保證使用它。有什麼我失蹤?我試過的TargetType設置爲「TransitionFrame」,但是,這並不正常工作,並拋出一個XAML解析異常(命名空間Microsoft.Phone.Controls.PhoneApplicationPages

<ControlTemplate x:Key="LoadingIndicatorTemplate" TargetType="toolkit:TransitionFrame" > 
          <Grid x:Name="ClientArea"> 
           <ContentPresenter /> 
           <Grid x:Name="ProgressGrid" Background="Black" Opacity="0.85" Visibility="Collapsed" Loaded="ProgressGrid_Loaded"> 
            <StackPanel x:Name="Loading" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="10"> 
             <TextBlock HorizontalAlignment="Center" Name="tbLoading" Text="Loading" Style="{StaticResource TextNormalStyle}" /> 
             <ProgressBar Style="{StaticResource PerformanceProgressBar}" HorizontalAlignment="Center" Name="pbLoading" Width="400" Margin="10" IsIndeterminate="False" /> 
            </StackPanel> 
           </Grid> 
          </Grid> 
        </ControlTemplate> 

回答

2

對於使用工具包對頁面過渡TransitionFrame以及自定義的控件模板,以顯示你的進度條,你必須指定TargetType的的控件模板作爲toolkit:Transitionframe其中工具被定義爲:

xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"

問題的其餘部分是您的ControlTemplate沒有指定TransitionFrame要求的模板部件。它需要一個名爲FirstContentPresenterSecondContentPresenterContentPresenter類型兩個部分組成。您的ControlTemplate更改爲以下,使頁面轉換回:

 <ControlTemplate x:Key="LoadingIndicatorTemplate" TargetType="toolkit:TransitionFrame"> 
      <Grid x:Name="ClientArea"> 
       <ContentPresenter x:Name="FirstContentPresenter" /> 
       <ContentPresenter x:Name="SecondContentPresenter" /> 
       <Grid x:Name="ProgressGrid" 
         Background="Black" 
         Opacity="0.85" 
         Visibility="Collapsed" 
         Loaded="ProgressGrid_Loaded"> 
        <StackPanel x:Name="Loading" 
           VerticalAlignment="Center" 
           HorizontalAlignment="Center" 
           Margin="10"> 
         <TextBlock x:Name="tbLoading" 
            HorizontalAlignment="Center" 
            Text="Loading" 
            Style="{StaticResource BoaTextNormalStyle}" /> 
         <toolkit:PerformanceProgressBar x:Name="pbLoading" 
                 HorizontalAlignment="Center" 
                 Width="400" 
                 Margin="10" 
                 IsIndeterminate="False" /> 
        </StackPanel> 
       </Grid> 
      </Grid> 
     </ControlTemplate> 

注:傑夫·威爾考克斯的PerformanceProgressBar現在是Silverlight工具包的一部分,這樣你就可以直接使用它,如上圖所示。

+0

謝謝德里克。我之前試過這個代碼,但問題依然如此。還有什麼我可以嘗試嗎? – 2011-04-13 23:49:19

+0

因此,對於正確類型的ControlTemplate和正確的xmlns,您不會得到XamlParseException,您可以獲取進度條,但是您不會獲取頁面轉換? – 2011-04-14 06:52:00

+0

是的。進度條可以顯示正常,所有頁面也一樣,但實際的頁面轉換不再存在。我已經用實際的ControlTemplate更新了原始帖子。 – 2011-04-14 19:54:19

0

如果你把進度條的框架上,但隨後動畫頁面那麼動畫將不包含進度條。

爲什麼不直接在頁面上放置進度條?

+0

動畫根本不會發生。我不想在頁面上的進度條,因爲它可以在30+的網頁應用程序的存在。 – 2011-04-09 01:33:06

+2

@willmel:30多頁的應用程序看起來像導航噩夢 – Praetorian 2011-04-13 22:12:51

+0

謝謝,但它會沒事的。 – 2011-04-13 22:25:56