2011-03-08 61 views
0

当我们选择ListBox项目时,我们会得到一个蓝色背景颜色对吗?我如何访问该风格并将其应用于不同的控件? 即我如何使用该选定的项目背景颜色作为别处的风格? 谢谢!ListBox SelectedItem背景颜色方案?

回答

0

的ListBoxItem中使用的颜色从systemColors中的类,它是从Windows拉动。具体而言,该触发器是什么样的变化背景:

<Trigger Property="IsSelected" 
Value="true"> 
<Setter TargetName="Bd" 
    Property="Background" 
    Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/> 
<Setter Property="Foreground" 
    Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/> 
</Trigger> 

所以你可以使用它像上面(即背景=“{DynamicResource {X:静态SystemColors.HighlightBrushKey}}”,或者你可以直接访问颜色(即“{x:Static SystemColors.HighlightBrush}”)

同样适用于代码隐藏