【问题标题】:UWP pivot items styleUWP 数据透视项目样式
【发布时间】:2018-10-08 05:34:55
【问题描述】:

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

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

【问题讨论】:

    标签: xaml xamarin uwp styles


    【解决方案1】:

    如果你只想设置整个pivot item的背景颜色,你可以设置它的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>
    

    【讨论】:

      猜你喜欢
      • 2012-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-14
      • 1970-01-01
      • 2016-08-16
      • 2016-07-19
      相关资源
      最近更新 更多