Search code examples
xamlwindows-phone-7background-colorstackpanel

Set StackPanel background to WP7 selected accent (theme) color


I am wondering if it is possible to set the background of my StackPanel to the Windows Phone 7 user selected accent (theme) color. I have heard that you are supposed to use styles so it can be used for all the StackPanels on the current xaml page. However I am a bit lost.

Example of my current static background color:

<StackPanel Width="400" Background="#FF1BA1E2" Margin="0, 10, 0, 0" Tag="ABC">
       <TextBlock Text="ABC" FontSize="50" Margin="10" />
</StackPanel>

Thanks for the help in advance.

PS: Just in case anyone is wondering the hexadecimal value "#FF1BA1E2" is the color of the default WP7 blue accent (theme).


Solution

  • Use the built in static resources to automatically get the theme color:

    Background="{StaticResource PhoneAccentBrush}"