Reputation: 185
How can I universally set the color of a checkbox/radiobutton throughout my app?
I am able to change the accent color like so
(App.Current.Resources["PhoneAccentBrush"] as SolidColorBrush).Color = System.Windows.Media.Color.FromArgb(255, 162, 0, 37);
But it is not applied to the checkboxes, radiobuttons, when pressed. I tried
App.Current.Resources["CheckBoxPressedBackgroundThemeBrush"] = System.Windows.Media.Color.FromArgb(255, 162, 0, 37);
App.Current.Resources["PhoneRadioCheckBoxPressedColor"] = System.Windows.Media.Color.FromArgb(255, 162, 0, 37);
Both these return a not implemented exception.
Upvotes: 0
Views: 781
Reputation: 842
You can change color of SolidColorBrush
in code
(App.Current.Resources["PhoneRadioCheckBoxCheckBrush"] as SolidColorBrush).Color = System.Windows.Media.Color.FromArgb(255,
162, 0, 37);
(App.Current.Resources["PhoneRadioCheckBoxPressedBrush"] as SolidColorBrush).Color = System.Windows.Media.Color.FromArgb(255,
162, 0, 37);
you can also make implicit style and put it in App.xaml resources and it will be applied to all instances of this control (except when you refer in some control to explicit style)
For example: Right Click on RadioButton Edit template Edit a copy choose Define in Application choose Apply to all
Change colors based on your scenario.
Upvotes: 2
Reputation: 2617
you can use Isolated Settings
Application.Current.IsolatedSetings.Add("YOur Key",System.Windows.Media.Color.FromArgb(255, 162, 0, 37).ToString())
AND USE WHEN NEEDED
VIA
var color = Application.Current.IsolatedSetings["Your Key"]
Upvotes: 0