2

我想更改 Pivot 项目的标题颜色以匹配主题颜色。但我也想在某些情况下将其更改回默认颜色(黑色或白色取决于设置中的背景设置)。我该怎么做。赞赏!

<phone:PivotItem x:Name="pivot_vip">
<phone:PivotItem.Header>
<TextBlock Text="{Binding Path=LocalizedResources.Artists, Source={StaticResource LocalizedStrings}}"/>
</phone:PivotItem.Header>

private void View_selection_changed(

    ...

    PivotItem currentItem = e.AddedItems[0] as PivotItem;
    if (currentItem != null)
    {
        if (current_view == HanlderType.EVIPHandler)
        {
            (currentItem.Header as TextBlock).Foreground = ??? //Theme color
        }
        else
        {
            (currentItem.Header as TextBlock).Foreground = **???** //whatever default 
        }
    }
4

1 回答 1

2

PhoneForegroundBrush根据当前系统主题,使用白色或黑色的资源键。

(currentItem.Header as TextBlock).Foreground = 
           (SolidColorBrush)App.Current.Resources["PhoneForegroundBrush"];
于 2013-05-30T06:09:14.183 回答