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

Die*_*hon 3 wpf resources systemcolors

我正在使用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>
Run Code Online (Sandbox Code Playgroud)

问题是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-->
Run Code Online (Sandbox Code Playgroud)

H.B*_*.B. 10

我使用这种常用技术来隐藏ListBox选项,它不用于任何东西

如果你没有使用任何选择,你应该只使用ItemsControl.