我在每个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>
我使用的东西,每次当Silverlight中加载它来解析XAML中页面的时间。所以当我有一个模板而不是树时,它应该花费更少的时间来解析它。我对吗? – 2010-12-14 09:53:09
这个特别的优化是一个有趣的问题。正如我们所知,Pivot延迟加载项目。有人可能会决定仔细研究并核实。我是一个分析的粉丝,除非有一个确定的优化,我知道会产生一个结果。 – 2010-12-14 13:03:25