2010-12-14 139 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