0

I am trying to center the pivot header in my universal 10 app,my code is this:

 <Pivot>
    <PivotItem x:Name="pivot0" Margin="0">
        <PivotItem.Header >
           <Image x:Name="headerimg" Source="images/1.png"  PointerExited="pointerExited" Height="40" Stretch="Uniform" PointerMoved="headerimg_PointerMoved" />
        </PivotItem.Header>
        <Grid >

        </Grid>
    </PivotItem>

    <PivotItem>
       <PivotItem.Header>
           <Image x:Name="headerimg1" Source="images/2.png"  Height="40" Stretch="Uniform" PointerExited="headerimg1_PointerExited" PointerMoved="headerimg1_PointerMoved" />
       </PivotItem.Header>
       <Grid>
          <TextBlock Text="test3"></TextBlock>
       </Grid>
    </PivotItem>
</Pivot>

I have an idea to use a header template,but I don't know how can I center the pivot header, thanks for help

Romasz
  • 29,662
  • 13
  • 79
  • 154
user3821206
  • 609
  • 1
  • 9
  • 22
  • 1
    You can always edit the style of *Pivot* and customize it like you want. – Romasz Dec 16 '15 at 22:15
  • 1
    As far I remember, you can't center the pivot header easily, you have to set a fix size. If you don't, the next header will be place just on the right of the last one. – arya404 Dec 16 '15 at 22:25

1 Answers1

3

Take a look at a complete example on how to do this here: https://blog.hompus.nl/2015/09/04/responsive-pivot-headers-in-universal-windows-platform-apps/

Import parts are

  • Setting the HorizontalContentAllignment to get the centering > <Setter Target="HeaderClipper.HorizontalContentAlignment" Value="Center" />
  • Taking care of the incorrect default height of a pivot header! The default template has 48 set as height and that would not be enough in most cases!
Depechie
  • 6,102
  • 24
  • 46