0

由于 Silverlight for Windows Phone 中没有Border.Effect属性,我设法重新创建了类似的效果。编辑 Pivot 控件的阶梯后出现的情况是:

在此处输入图像描述

如您所见,该项目是 Visual Studio 默认模板之一。使用我的自定义样式,ItemsPanel 位于黑色/灰色渐变的后面,因此,当您滚动列表时,就像项目正在消失一样。

<Style x:Key="PivotStyle1" TargetType="controls:Pivot">
            <Setter Property="Margin" Value="0"/>
            <Setter Property="Padding" Value="0"/>
            <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="ItemTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <ItemsPanelTemplate>
                            <Grid />
                        </ItemsPanelTemplate>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="controls:Pivot">
                        <Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="70" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Grid Background="{TemplateBinding Background}" CacheMode="BitmapCache" Grid.RowSpan="3"/>

                            <Grid Grid.Row="1">
                                <ItemsPresenter x:Name="PivotItemPresenter" Margin="{TemplateBinding Padding}" VerticalAlignment="Top"/>

                                <Grid Height="50" VerticalAlignment="Top">
                                    <Grid.Background>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#66000000" Offset="0"/>
                                            <GradientStop Offset="1"/>
                                            <GradientStop Color="#19000000" Offset="0.523"/>
                                        </LinearGradientBrush>
                                    </Grid.Background>
                                </Grid>
                            </Grid>



                            <Grid Height="70" Grid.Row="0" VerticalAlignment="Top">
                                <Grid.Background>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#FF1665CD" Offset="1"/>
                                        <GradientStop Color="#FF5395EC"/>
                                    </LinearGradientBrush>
                                </Grid.Background>
                                <Primitives:PivotHeadersControl x:Name="HeadersListElement"/>
                            </Grid>

                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

问题是每当我滑向PivotItems两个带有渐变背景的网格时都会闪烁。可能是什么问题呢?

更新:仅当我导航回此页面时才会出现闪烁

4

2 回答 2

1

解决CacheMode了对Grid元素的设置。例如:

<Grid Height="70" CacheMode="BitmapCache" Grid.Row="0" VerticalAlignment="Top">
                                <Grid.Background>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#FF1665CD" Offset="1"/>
                                        <GradientStop Color="#FF5395EC"/>
                                    </LinearGradientBrush>
                                </Grid.Background>
                                <Primitives:PivotHeadersControl x:Name="HeadersListElement"/>
                            </Grid>
于 2013-09-11T12:41:37.133 回答
0

与其重新设置 Pivot 的样式以添加背景,您可能会发现创建单个图像以用作页面背景并将 Pivot 背景保持为透明要容易得多。

于 2013-09-11T09:17:55.607 回答