Reputation: 4056
I would simply like to customize my application bar so that under certain states different default theme colors are used. This is to give a little different feel to the standard application bar. My trouble is setting the foreground and background colors to theme resource colors. I am getting an invalid Cast exception when trying the following
ApplicationBar.ForegroundColor = (Color)Application.Current.Resources["PhoneChromeBrush"];
and I am not sure why? To note, no explicit error occurs before debugging.
Upvotes: 2
Views: 375
Reputation: 15006
Use
ApplicationBar.ForegroundColor = (Application.Current.Resources["PhoneChromeBrush"] as SolidColorBrush).Color;
because that resource is a brush (hence the name PhoneChromeBrush) therefore you have to convert it to SolidColorBrush first and then get the Color property from it.
Upvotes: 1