1

I know that pivot control of windows phone has two parts pivot headers and pivot item control.

what i want to display is, pivot headers below the pivot item control (or pivot footers).

But i found this this thing is not available in pivot control.

Is there any other way, to display tabs at the footer of wp7 app.

thanks and regards

Mohit
  • 415
  • 2
  • 18

2 Answers2

2

You can create your own style for Pivot control. The easiest way to move header down is create a copy of default Pivot style and slightly modify it.

    <Style x:Key="PivotStyle" 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="*"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Grid Background="{TemplateBinding Background}" CacheMode="BitmapCache" Grid.RowSpan="3"/>
                        <ContentPresenter ContentTemplate="{TemplateBinding TitleTemplate}" Content="{TemplateBinding Title}" Margin="24,17,0,-7"/>
                        <ItemsPresenter x:Name="PivotItemPresenter" Margin="{TemplateBinding Padding}" Grid.Row="1"/>
                        <controlsPrimitives:PivotHeadersControl x:Name="HeadersListElement" Grid.Row="2"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

<controls:Pivot Title="pivot" Style="{StaticResource PivotStyle}">

Ku6opr
  • 8,126
  • 2
  • 24
  • 31
0

I have the solution. You need to inherit from Pivot control and switch headers row with items row:

  public class PivotFooter : Pivot
  {
    public override void OnApplyTemplate()
    {
      base.OnApplyTemplate();

      var headers = base.GetTemplateChild("HeadersListElement") as PivotHeadersControl;
      var items = base.GetTemplateChild("PivotItemPresenter") as ItemsPresenter;

      var grid = headers.Parent as Grid;
      if(grid != null)
      {
        var firstHeight = grid.RowDefinitions[1].Height;
        var secondHeight = grid.RowDefinitions[2].Height;

        grid.RowDefinitions[1].Height = secondHeight;
        grid.RowDefinitions[2].Height = firstHeight;    
      }

      headers.SetValue(Grid.RowProperty, 2);
      items.SetValue(Grid.RowProperty, 1);
    }
  }
Ivan Bianko
  • 1,749
  • 15
  • 22