I have textbox in xaml
<TextBlock Style="{StaticResource PhoneTextExtraLargeStyle}" FontSize="{StaticResource PhoneFontSizeLarge}" FontFamily="{StaticResource PhoneFontFamilySemiLight}" Margin="12,10,12,0" />
How can I get value of phoneaccentbrush, programmatically (c#) from system resource of windows phone 7 / 7.5 / 8 so that i can set the foreground-color to match the accent selected in the WP's settings.
First, you need to create currentAccentColorHex before Constructor of you C# class:
public partial class MainPage : PhoneApplicationPage
{
Color currentAccentColorHex = (Color)Application.Current.Resources["PhoneAccentColor"];
// Constructor
public MainPage()
{
//...
and then use it wherever you need to set color for the control: Example for Background property for control MyControl:
SolidColorBrush backColor = new SolidColorBrush(currentAccentColorHex);
MyControl.Background = backColor;
Hope this help
thanks Spaso :) I did little more research and with your help I came up with following code
var phoneAccentBrush = new SolidColorBrush((App.Current.Resources["PhoneAccentBrush"] as SolidColorBrush).Color);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With