0

我如何为枢轴项设置两个不同的背景,例如“全部”为蓝色,“非全部”为红色。

<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>
4

1 回答 1

1

如果你只想设置整个数据透视项的背景颜色,你可以设置它的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>
于 2018-04-27T20:41:16.223 回答