Windows phone 8 枢轴头部模板对齐
下面是我的Pivot控件在我的WP应用程序上的外观 下面是相同的代码Windows phone 8 枢轴头部模板对齐,windows-phone-8,windows-phone,Windows Phone 8,Windows Phone,下面是我的Pivot控件在我的WP应用程序上的外观 下面是相同的代码 <phone:Pivot> <!--Pivot item one--> <phone:PivotItem> <phone:PivotItem.Header> <ContentControl> <
<phone:Pivot>
<!--Pivot item one-->
<phone:PivotItem>
<phone:PivotItem.Header>
<ContentControl>
<Image Source="/Assets/alarmClock.png"/>
</ContentControl>
</phone:PivotItem.Header>
<Grid>
<TextBlock Text="hello1"/>
</Grid>
</phone:PivotItem>
<!--Pivot item two-->
<phone:PivotItem >
<phone:PivotItem.Header>
<ContentControl>
<Image Source="/Assets/clock.png"/>
</ContentControl>
</phone:PivotItem.Header>
<Grid>
<TextBlock Text="hello 2"/>
</Grid>
</phone:PivotItem>
<!--Pivot item three-->
<phone:PivotItem>
<phone:PivotItem.Header>
<ContentControl>
<Image Source="/Assets/timer.png"/>
</ContentControl>
</phone:PivotItem.Header>
<Grid>
<TextBlock Text="hello 3"/>
</Grid>
</phone:PivotItem>
</phone:Pivot>
我想自定义标题的外观。这就是我希望标题自身对齐的方式(参见下图)。我不知道该怎么做。下面是我想要的黑色网格和垂直管道的外观。有人能帮我吗?我想我也得写一个同样的风格。但是,我不知道我可以用什么方式定义样式,以便按照下面的说明更改对齐方式。
越接近您想要实现的目标,您就越不费吹灰之力:
<phone:PhoneApplicationPage.Resources>
<DataTemplate x:Key="PivotHeader">
<Grid Margin="-11,0,-11,0">
<Border BorderBrush="#FFF70000" BorderThickness="1">
<Grid Width="152" HorizontalAlignment="Center">
<Image Height="80" Source="{Binding}"></Image>
</Grid>
</Border>
</Grid>
</DataTemplate>
</phone:PhoneApplicationPage.Resources>
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<!--Pivot Control-->
<phone:Pivot HeaderTemplate="{StaticResource PivotHeader}">
<phone:PivotItem Header="/Assets/Clock.png">
<Grid>
<TextBlock Text="hello 1"/>
</Grid>
</phone:PivotItem>
<phone:PivotItem Header="/Assets/Clock.png">
<Grid>
<TextBlock Text="hello 2"/>
</Grid>
</phone:PivotItem>
<phone:PivotItem Header="/Assets/Clock.png">
<Grid>
<TextBlock Text="hello 3"/>
</Grid>
</phone:PivotItem>
</phone:Pivot>
</Grid>
但是,您会注意到,轴控件的工作方式与和上的选项卡不同
我也不建议更改Windows Phone中pivot控件的行为
也许实现您要做的事情的最好方法是使用数据透视页面顶部的按钮,并通过修改数据透视选择来手动处理它们的行为。您是否尝试过使用网格而不是内容控制?然后在网格内设置图像中心对齐?也可以有边框,边框颜色设置为黑色,边框厚度设置为1。