2013-05-30 73 views
2

我想更改Pivot項目的標題顏色以匹配主題顏色。但是我也想在某些條件下將其更改回默認顏色(黑白或取決於設置中的背景設置)。我該怎麼做。不勝感激!WP:如何將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 
     } 
    } 

回答

2

使用PhoneForegroundBrush資源鍵,根據當前的系統主題,它可以是白色或黑色。

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

感謝您快速回答!我改變了一些問題。如何將顏色更改爲默認標題?例如,默認爲黑色或白色(取決於設置/主題/背景[黑白]中的設置) – thsieh

+0

根據當前主題,我的答案會爲您提供默認標題顏色。 –

相關問題