ListBox and ListView Highlighting .NET 4.0

狂风中的少年 提交于 2019-12-01 21:51:37

With .NET 4.0 there are some new SytemColors
This appears to be the .NET 4.0 way According to comment this changed in 4.5 - not 4.0.

<ListBox.ItemContainerStyle>
    <Style>
        <Style.Resources>
            <!-- Foregroud of selected item when focussed -->
            <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Red"/>
            <!-- Foregroud of selected item when not focussed -->
            <SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}" Color="Green"/>
            <!-- Background of selected item when focussed -->
            <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Pink"/>
            <!-- Background of selected item when not focussed -->
            <SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" Color="Yellow" />
        </Style.Resources>
    </Style>
</ListBox.ItemContainerStyle> 

At first I though the definition of ControlBrushKey had changed but it has not
It appears the behavior of ControlBrushKey has changed in this situation

Note the behavior changes with GridView

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!