2010-12-14 64 views
0

我在每個PevotItem中都有了ListBox控件。我爲ListBoxes中的動畫項目製作了Button控件。有那些按鈕的樹 - 它們中的每一個都有不同的圖像。但是,也許有一些方法可以讓一個按鈕綁定圖像源。我認爲這會改善加載頁面時間。windows phone 7,按鈕模板圖片源碼綁定

我會感謝任何答案。

這裏是我的代碼:

<DataTemplate x:Key="pageItemTemplate"> 
     <Button Content="{Binding name}" Margin="0,0,0,20" Style="{StaticResource PageListItemButton}"/> 
    </DataTemplate> 




<Style x:Key="PageListItemButton" TargetType="Button"> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="Button"> 
        <StackPanel x:Name="stackPanel" Orientation="Horizontal"> 
         <StackPanel.Projection> 
          <PlaneProjection CenterOfRotationY="0" CenterOfRotationX="1"/> 
         </StackPanel.Projection> 
         <VisualStateManager.VisualStateGroups> 
          <VisualStateGroup x:Name="CommonStates"> 
           <VisualStateGroup.Transitions> 
            <VisualTransition GeneratedDuration="0:0:0.05"> 
             <VisualTransition.GeneratedEasingFunction> 
              <CircleEase EasingMode="EaseInOut"/> 
             </VisualTransition.GeneratedEasingFunction> 
            </VisualTransition> 
           </VisualStateGroup.Transitions> 
           <VisualState x:Name="Normal"/> 
           <VisualState x:Name="MouseOver"/> 
           <VisualState x:Name="Pressed"> 
            <Storyboard> 
             <DoubleAnimation Duration="0" To="15" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="stackPanel" d:IsOptimized="True"/> 
             <DoubleAnimation Duration="0" To="0.7" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="stackPanel" d:IsOptimized="True"/> 
            </Storyboard> 
           </VisualState> 
           <VisualState x:Name="Disabled"/> 
          </VisualStateGroup> 
         </VisualStateManager.VisualStateGroups> 
         <Image Source="Images/MainPage/page.png" Height="40" Stretch="Fill" Width="40"/> 
         <ContentPresenter VerticalAlignment="Bottom"/> 
        </StackPanel> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
     <Setter Property="FontFamily" Value="/BestNote;component/Fonts/Fonts.zip#Diavlo Bold"/> 
     <Setter Property="FontWeight" Value="Bold"/> 
     <Setter Property="FontSize" Value="24"/> 
     <Setter Property="Foreground" Value="#FF292929"/> 
    </Style> 

回答

0

如果你發現一個圖像(大小爲一個按鈕)的加載時間基本上足以導致延遲打開的頁面,或許可以將圖像縮小在尺寸上更適合於這種尺寸的圖像。

另外,也許做一些分析,以確定什麼是真正的花時間來加載此頁面..它可能不是圖像佔大多數時間。

您可以使用調試輸出和TimeSpans進行簡單的分析,或者嘗試類似EQATEC分析器。

+0

我使用的東西,每次當Silverlight中加載它來解析XAML中頁面的時間。所以當我有一個模板而不是樹時,它應該花費更少的時間來解析它。我對嗎? – 2010-12-14 09:53:09

+0

這個特別的優化是一個有趣的問題。正如我們所知,Pivot延遲加載項目。有人可能會決定仔細研究並覈實。我是一個分析的粉絲,除非有一個確定的優化,我知道會產生一個結果。 – 2010-12-14 13:03:25