Yesterday I needed to change the IsOn background color of a ToggleSwitch. There is no exposed property allowing you to update this color. And if you extract a copy of the default template, you’ll find that the blue color pictured below comes from a Rectangle with its Fill property bound directly to the ThemeResource “SystemControlHighlightAccentBrush”.
Frustrated that this property was not exposed, I plopped a copy of the default template into my ResourceDictionary and modified the Rectangle Fill directly. Having to deal with the stiffness of XAML templates previously, I decided to
whine vent online about it on Twitter to commiserate with others and hopefully find out that I was wrong.
Want to change the background color of a ToggleButton in #win10? You have to overwrite the 196-line XAML template, just to change one color.
— Adam Kinney (@adkinn) August 27, 2015
Good news! I was wrong.
Thanks go to @wiredprairie for pointing out ThemeDictionaries overrides. As the title suggest you can override specific colors which will then cascade across all of the controls tied to that ThemeResource. In this case instead of adding a copy of the ToggleSwitch template, you can add the following code to your Application.
<SolidColorBrush x:Key="SystemControlHighlightAccentBrush" Color="HotPink"/>
And you end up with the following updated control, averaging around 191 less lines, much less complexity and less crying.