2012-02-16 70 views
0
<Style TargetType="ListBoxItem"> 
     <Style.Resources> 
      <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" /> 
      <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" /> 
      </Style.Resources> 
     <Style.Triggers> 
      <Trigger Property="IsSelected" Value="True"> 
       <Setter Property="Background" Value="White" />     
      </Trigger> 
     </Style.Triggers> 
    </Style> 

上述代码旨在防止任何高亮颜色用作我的列表框项目的“选择指示符”。我的程序有一个完全白色的背景,我打算使用一些自定义动画来代替选择。上面的代码确实删除了传统的蓝色突出显示,但它也使文本(在项目容器内)完全消失,所以我看到的只是一个白色项目。将列表框高亮颜色设置为空

任何想法?

回答

0

在您的样式中,在IsSelected触发器中,添加一个Setter以将Foreground设置为所需的颜色而不是白色。我通常在ItemContainerStyle中执行此操作,但它也应该在ListBoxItem样式中工作。

+0

干杯!这工作完美。 – randomalbumtitle 2012-02-17 04:34:56