UWP枢轴项目样式



我如何设置枢轴项目的两个不同背景,例如" all"one_answers" notall"的红色。

<Pivot x:Name="Pivot" HorizontalContentAlignment="Center"">    
    <PivotItem Header="All" x:Name="All">
        <ListView
            ItemsSource="{Binding Source={StaticResource AllList}}"
            SelectionMode="None">            
        </ListView>
    </PivotItem>
    <PivotItem x:Name="NotAll" Header="Not All">
        <ListView
            ItemsSource="{Binding Source={StaticResource NotAllList}}"
            SelectionMode="None">
        </ListView>
    </PivotItem>
</Pivot>

如果您只想设置整个枢轴项目的背景颜色,则可以设置其Background属性:

<Pivot x:Name="Pivot" HorizontalContentAlignment="Center">
    <PivotItem Background="Blue" ...>
        ...
    </PivotItem>
    <PivotItem Background="Red" ...>
        ...
    </PivotItem>
</Pivot>

另外,如果要更改标题文本的颜色,则可以使用复杂的属性语法,然后将标题设置为自定义控件:

<PivotItem x:Name="NotAll">
    <PivotItem.Header>
        <TextBlock Foreground="Red" Text="Not all" />
    </PivotItem.Header>
    ...
</PivotItem>

最新更新