windows-phone-8 - 可湿性粉剂 : How do I change foreground color of Pivot title to theme color or default color

标签 windows-phone-8 pivot foreground

我想更改数据透视项的标题颜色以匹配主题颜色。但我也想在某些情况下将其更改回默认颜色(黑色或白色,具体取决于“设置”中的背景设置)。我该怎么办呢。赞赏!

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

最佳答案

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

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

关于windows-phone-8 - 可湿性粉剂 : How do I change foreground color of Pivot title to theme color or default color,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16828932/

相关文章:

windows-runtime - WP8 : can't consume a native component

c# - 当背景为白色时,如何在 Windows Phone 8 中为列表框赋予颜色?带有图像按钮

windows-phone-7 - 是否可以查看有多少人在 Windows Phone 上卸载了我的应用程序?

sql-server-2008 - 透视动态列,无聚合

objective-c - 如何将一个 NSImageView 置于另一个 NSImageView 的前面或后面?

python - 使用 nohup (LINUX) 访问后台工作的进度 - 获取前台

android - 如何使本地 USB 端口与 Azure 虚拟机配合使用

Mysql 对旋转或转置值的计数

mysql - 我的 table 组织不当的另一个问题

android - 以编程方式在Android中的FrameLayout中设置前景色