[英]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. 我想知道是否可以将StackPanel的背景设置为Windows Phone 7用户选择的重音(主题)颜色。 I have heard that you are supposed to use styles so it can be used for all the StackPanels on the current xaml page. 我听说你应该使用样式,因此它可以用于当前xaml页面上的所有StackPanel。 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). PS:万一有人想知道十六进制值“#FF1BA1E2”是默认WP7蓝色重音(主题)的颜色。
使用内置的静态资源自动获取主题颜色:
Background="{StaticResource PhoneAccentBrush}"
i have encountered the same exception while trying this. 我在尝试这个时遇到了同样的异常。 just try Apply Binding to the Background
through Properties tab. 只需通过“属性”选项卡尝试“将绑定应用于Background
。 or hardcode this into the xaml file, to the stackpanel element 或者将其硬编码到xaml文件中,然后硬编码到stackpanel元素
Background="{Binding Source={StaticResource PhoneAccentBrush}}"
it solves the exception. 它解决了这个例外。 :) :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.