【问题标题】:How to override the PhoneAccentBrush in WindowsPhone?如何覆盖 Windows Phone 中的 Phone Accent Brush?
【发布时间】:2012-06-22 13:40:20
【问题描述】:

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

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

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

【问题讨论】:

    标签: c# xaml windows-phone-7.1


    【解决方案1】:

    如下添加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

    【讨论】:

      【解决方案2】:

      您不能覆盖 PhoneAccentBrush。这是一个“系统”资源。但是您可以更改 ListPicker 的行为方式。请参阅http://windowsphonegeek.com/articles/customizing-listpicker-for-wp7-part1 了解一系列说明如何操作的文章。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-12-16
        • 1970-01-01
        相关资源
        最近更新 更多