0

我在每个 PevotItem 中都有带有 ListBoxes 的 Pivot。我已经为 ListBoxes 中的项目制作了 Button 控件。有这些按钮的树 - 每个按钮都有不同的图像。但是,也许有一些方法可以制作一个 Button 并绑定图像源。我认为这将改善加载页面时间。

我会感谢任何答案。

这是我的代码:

    <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>
4

2 回答 2

0

也许您会对以下文章感兴趣:

http://silvergeek.net/2011/01/14/imagebutton-control-for-win-phone-7/

于 2011-01-14T10:59:39.713 回答
0

如果您发现一张图片(按钮大小)的加载时间足以导致打开页面的延迟,也许可以将图片缩小到更适合该尺寸图片的尺寸。

或者,也许做一些分析以确定实际花费时间加载此页面的内容.. 它可能不是大部分时间占用的图像。

您可以使用调试输出和 TimeSpan 进行简单的分析,或者尝试使用 EQATEC 分析器之类的东西。

于 2010-12-14T09:38:37.417 回答