c# - Set Control Styles to ThemeResource Values Programmatically In Windows Phone 8.1 -
i'm adding controls dynamically in windows phone 8.1 application. in xaml, can set various styles current theme's style set foreground attribute of textblock control in following example.
<textblock text="hello world" foreground="{themeresource phoneaccentbrush}" />
i want able same thing in code behind, have not yet been able determine how this. create textblock programmatically follows.
textblock textblock = new textblock() { text = "hello world", foreground = // need phone accent brush theme };
i've seen examples different theme values stored follows, dictionary doesn't seem contain keys when checked theme resources.
solidcolorbrush phoneaccent = new solidcolorbrush((color)application.current.resources["phoneaccentcolor"]);
any appreciated. thank you!
load phoneaccentbrush not phoneaccentcolor:
brush accentbrush = resources["phoneaccentbrush"] brush; textblock textblock = new textblock() { text = "hello world", foreground = accentbrush };