微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

列表/组合框背景和选定的颜色.net 4.5

我有一个应用程序在 Windows 7和更低版本上运行愉快,以.net 4框架为目标.
如果应用程序现在安装在Windows 8(运行.net 4.5,但仍然定位.net 4),它将显示列表框或组合框中的选定项目的蓝色背景,以及重点项目的白色背景.有没有删除这个?
我在我的XAML中使用以下内容来设置问题的风格,这似乎解决了Windows 8之前的问题.
<ListBox.ItemContainerStyle>
                <Style targettype="{x:Type ListBoxItem}">
                    <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
                    <Style.Resources>
                        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
                        <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent"/>
                    </Style.Resources>
                </Style>
            </ListBox.ItemContainerStyle>
我忘了回来,我如何解决这个问题….原来,所有你需要做的,它创建一个空的项目容器样式,并将其分配到你的列表框/组合框等….你可以使用这个以及保持您可能使用的当前样式,如ListBox Style =“{StaticResource CurrentStyle}”ItemContainerStyle =“{StaticResource BlankListBoxContainerStyle}”/>其中BlankListBoxContainerStyle会像…
<Style x:Key="BlankListBoxContainerStyle" targettype="{x:Type ListBoxItem}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate targettype="{x:Type ListBoxItem}">
                <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
    <Setter Property="FocusVisualStyle"
            Value="{x:Null}"/>
</Style>

原文地址:https://www.jb51.cc/windows/371024.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐