WPF组合框列出项目背景问题



我仍在学习WPF,并且正在使用组合框控件。我正在尝试设置组合框,使其背景是透明的,当你点击它时,显示的列表项是透明的。

在网上阅读了一些内容后,我开始导出combobox控件模板和列表项模板,并开始对此进行修补。我现在已经将组合框本身设置为透明的,并且已经找到了当鼠标悬停在列表项上时如何更改列表项,但仍然没有找到如何更改组合框在尚未选择任何内容时用于显示列表项的"默认"白色背景。。

我假设它在组合框列表项模板中。。。有人知道我需要在那里换什么吗?(如果有帮助的话,我想要的是组合框和项目是透明的,这样网格背景就会显示出来,然后我可以使用列表项鼠标将用户指向的列表项中的条目更改为不同的背景。我已经弄清楚了这一部分,但仍在努力弄清楚如何从一开始就让它们都"透明"。

提前感谢。

好吧,在处理了这个问题并搜索了一点之后,我终于在这里找到了它

  <ControlTemplate x:Key="ComboBoxTemplate" TargetType="{x:Type ComboBox}">
        <Grid x:Name="templateRoot" SnapsToDevicePixels="true">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/>
            </Grid.ColumnDefinitions>
            <Popup x:Name="PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2" IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Margin="1" Placement="Bottom" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}">
                <theme:SystemDropShadowChrome x:Name="shadow" Color="Transparent" MinWidth="{Binding ActualWidth, ElementName=templateRoot}" MaxHeight="{TemplateBinding MaxDropDownHeight}">
                    <Border x:Name="dropDownBorder" Background="Transparent" BorderThickness="1" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}">

我将dropDownBorderBackground属性更改为Transparent,并修复了它…

最新更新