gpt4 book ai didi

wpf - 隐藏 WPF ListBox 中的选择,将其保留在包含的控件中

转载 作者:行者123 更新时间:2023-12-01 07:30:26 24 4
gpt4 key购买 nike

我正在使用 ListBox 来显示可编辑对象的列表,其模板中包含一个 ComboBox。

我使用了这个常用技术来隐藏 ListBox 选择,它不用于任何事情:

<ListBox.Resources>
<Style TargetType="ListBoxItem">
<Style.Resources>
<Brush x:Key="{x:Static SystemColors.HighlightBrushKey}">Transparent</Brush>
<Brush x:Key="{x:Static SystemColors.ControlBrushKey}">Transparent</Brush>

问题是这与 ComboBox 下拉列表选择困惑。

我想在我的模板中再次覆盖这些资源,指定原始值( SystemColors.HighlightBrush 等)而不是对它们进行硬编码。我怎样才能做到这一点?
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type SearchService:Criterion}">
<DataTemplate.Resources>
<!--I know how to specify a hardcoded brush here,
but not how to reference one from SystemColors-->

最佳答案

I used this common technique to hide the ListBox selection, which is not used for anything



如果你不使用任何选择,你应该使用 ItemsControl 反而。

关于wpf - 隐藏 WPF ListBox 中的选择,将其保留在包含的控件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5637356/

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