gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 23:30:31 24 4
gpt4 key购买 nike

我有一个在 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>

关于.net - .net 4.5 下的列表/组合框背景和选定颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12007918/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com