WP:如何将Pivot标题的前景色更改为主题颜色或默认颜色

时间:2013-05-30 05:55:21

标签: windows-phone-8 pivot foreground

我想更改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 
        }
    }

1 个答案:

答案 0 :(得分:2)

使用PhoneForegroundBrush资源键,该键将为白色或黑色,具体取决于当前系统主题。

(currentItem.Header as TextBlock).Foreground = 
           (SolidColorBrush)App.Current.Resources["PhoneForegroundBrush"];