I want to change Pivot item's title color to match theme color. But I also want to change it back to default color (Black or White depending on background setting in Settings) at some condition. How should I do it. Appreciated!
<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
}
}
Use PhoneForegroundBrush
resource key which will be either white or black depending on current system theme.
(currentItem.Header as TextBlock).Foreground =
(SolidColorBrush)App.Current.Resources["PhoneForegroundBrush"];