开发者

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开发者_如何学C 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).


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

Background="{StaticResource PhoneAccentBrush}"


i have encountered the same exception while trying this. just try Apply Binding to the Background through Properties tab. or hardcode this into the xaml file, to the stackpanel element

Background="{Binding Source={StaticResource PhoneAccentBrush}}"

it solves the exception. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜