【问题标题】:WP7 Custom Pivot control flickeringWP7 自定义 Pivot 控件闪烁
【发布时间】:2013-09-11 07:30:58
【问题描述】:

由于 Windows Phone 的 Silverlight 中没有 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 时,两个带有渐变背景的Grid 都会闪烁。可能是什么问题?

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

【问题讨论】:

    标签: silverlight xaml windows-phone-7 styles pivotviewer


    【解决方案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>
    

    【讨论】:

      【解决方案2】:

      您可能会发现创建单个图像用作页面背景并让 Pivot 背景保持透明,而不是重新设置 Pivot 的样式来添加背景。

      【讨论】:

      • 您不会是“最佳”解决方案,也不符合我的需求。 Infact 页面背景位于 PivotItem 内容后面,这不是我想要的。
      猜你喜欢
      • 2012-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-18
      • 2011-07-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多