如何覆盖Windows Phone中的Phone Accent Brush?

时间:2012-06-19 07:06:41

标签: c# xaml windows-phone-7.1

基本上,PhoneAccentBrush附带来自Phone的SelectedTheme强调色。但我总是需要BlueAccentBrush用于WindowsPhone应用程序中的特定xaml文件。

实际上我的要求是,当ListPicker在FullMode中时.Popup中的SelectedItem颜色取决于PhoneAccentBrush ...如果我将Phone主题设置为Red ..那么Popup中的SelectedItem颜色将为红色..但我不喜欢这个..我想要Popup中的SelectedItem总是BlueAccentBrush ..

所以任何人都可以帮我覆盖xaml文件中的PhoneAccentBrush ..

2 个答案:

答案 0 :(得分:2)

添加ListPicker,如下所示,

<StackPanel x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0" >     
<toolkit:ListPicker ListPickerMode="Full">
<toolkit:ListPickerItem Content="Item1"/>
<toolkit:ListPickerItem Content="Item1"/>
<toolkit:ListPickerItem Content="Item2"/>
<toolkit:ListPickerItem Content="Item3"/>
<toolkit:ListPickerItem Content="Item4"/>
</toolkit:ListPicker>
</StackPanel>

覆盖ListPicker所选项目颜色

<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:System="clr-namespace:System;assembly=mscorlib">
    <Color x:Key="PhoneAccentColor">Blue</Color>

    <SolidColorBrush x:Key="PhoneAccentBrush" Color="{StaticResource PhoneAccentColor}"/>
    <Style x:Key="PhoneTextAccentStyle" TargetType="TextBlock" BasedOn="{StaticResource PhoneTextBlockBase}">
        <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiBold}"/>
        <Setter Property="Foreground" Value="{StaticResource PhoneAccentBrush}"/>
    </Style>
</ResourceDictionary>

有关详细信息,请参阅以下示例:http://www.windowsphonegeek.com/upload/articles/MangoCustomApplicationTheme%20_1_2_3.zip

答案 1 :(得分:1)

您无法覆盖PhoneAccentBrush。这是一个“系统”资源。但是你可以改变ListPicker的行为方式。有关一系列展示如何使用的文章,请参阅http://windowsphonegeek.com/articles/customizing-listpicker-for-wp7-part1

相关问题