在枢轴控制中更改标题和标题的背景

Cod*_*odo 2 silverlight windows-phone-7

在我的Phone 7应用程序中,我使用了一个数据透视控件.现在我想改变其标题和标题区域的背景.我怎样才能做到这一点?

是否有可以自定义的枢轴控件的整体模板?

我已经尝试将包含pivot控件的网格背景设置为标题颜色,然后将每个pivot项的背景设置为原始背景颜色.一见钟情看起来不错.但是当您向左擦拭枢轴项目以显示第二个项目时,在两个枢轴项目之间会出现标题颜色的区域.所以这种方法不起作用.

此外,我试图自定义标题和标题项的模板.但这些模板仅涵盖文本本身的区域,而不是整个标题和模板区域.

Ost*_*mar 10

这是改变控件模板的变体.将Background ="Red"更改为您想要的任何画笔.

<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="ItemsPanel">
    <Setter.Value>
      <ItemsPanelTemplate>
        <Grid/>
      </ItemsPanelTemplate>
    </Setter.Value>
  </Setter>
  <Setter Property="Template">
    <Setter.Value>
      <ControlTemplate TargetType="controls:Pivot">
        <Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
              VerticalAlignment="{TemplateBinding VerticalAlignment}">
          <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
          </Grid.RowDefinitions>
          <Grid Background="Red" CacheMode="BitmapCache" Grid.RowSpan="2" />
          <Grid Background="{TemplateBinding Background}" CacheMode="BitmapCache"
                Grid.Row="2" />
          <ContentPresenter ContentTemplate="{TemplateBinding TitleTemplate}"
                            Content="{TemplateBinding Title}" Margin="24,17,0,-7"/>
          <controlsPrimitives:PivotHeadersControl x:Name="HeadersListElement"
                                                  Grid.Row="1"/>
          <ItemsPresenter x:Name="PivotItemPresenter"
                          Margin="{TemplateBinding Padding}" Grid.Row="2"/>
        </Grid>
      </ControlTemplate>
    </Setter.Value>
  </Setter>
</Style>

....

<controls:Pivot Title="MY APPLICATION" Style="{StaticResource PivotStyle1}">

....
Run Code Online (Sandbox Code Playgroud)