C# WPF组合框项模板覆盖切换按钮样式

C# WPF组合框项模板覆盖切换按钮样式,c#,wpf,combobox,styles,C#,Wpf,Combobox,Styles,我对组合框的切换按钮的样式设置有问题。 我的combobox xaml代码如下所示: <ComboBox Width="Auto" HorizontalContentAlignment="Stretch" FontFamily="HelveticaNeue-Bold" FontSize="20" FontWeight="Bold" Foreground="#FFC0C0C0" Padding="0,0,0,0"

我对组合框的切换按钮的样式设置有问题。 我的combobox xaml代码如下所示:

<ComboBox Width="Auto"
      HorizontalContentAlignment="Stretch"
      FontFamily="HelveticaNeue-Bold"
      FontSize="20"
      FontWeight="Bold"
      Foreground="#FFC0C0C0"
      Padding="0,0,0,0"
      Style="{DynamicResource navigationComboBox}"
      ItemsSource="{Binding Tournaments}"
      SelectedValue="{Binding SelectedTournament}">
<ComboBox.Resources>
    <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
</ComboBox.Resources>
<ComboBox.ItemsPanel>
    <ItemsPanelTemplate>
        <WrapPanel IsItemsHost="True" 
                    Orientation="Vertical" 
                    Width="auto"
                    Height="{Binding Tournaments, Converter={StaticResource CollectionToHeightConverter}}"/>
    </ItemsPanelTemplate>
</ComboBox.ItemsPanel>
<ComboBox.ItemTemplate>
    <DataTemplate>
        <DockPanel x:Name="comboDock">
            <DockPanel.Background>
                <ImageBrush ImageSource="{Binding Converter={StaticResource ImagePathConverter}, ConverterParameter=comboboxitem-line.png}" />
            </DockPanel.Background>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="50" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="41" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <DockPanel x:Name="comboArrow"
                            Grid.Column="0"
                            Visibility="Collapsed">
                    <DockPanel.Background>
                        <ImageBrush ImageSource="{Binding Converter={StaticResource ImagePathConverter}, ConverterParameter=SportsSubMenuActive.png}" />
                    </DockPanel.Background>
                </DockPanel>
                <TextBlock x:Name="comboText"
                            Grid.Column="1"
                            FontFamily="HelveticaNeue-Bold"
                            FontSize="20"
                            FontWeight="Bold"
                            Foreground="#FFC0C0C0"
                            Padding="0,0,10,0"
                            Text="{Binding Path=Name}"
                            TextAlignment="Left"
                            TextWrapping="Wrap" />
            </Grid>
        </DockPanel>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=ComboBoxItem}}" Value="True">
                <Setter TargetName="comboArrow" Property="Visibility" Value="Visible" />
                <Setter TargetName="comboText" Property="Foreground" Value="#F94B01" />
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>
</ComboBox.ItemTemplate>

所以我试图删除设置为on togglebutton的背景,但这是不可能的。如果删除itemtemplate上的背景,则可以设置切换按钮背景的样式。如果togglebutton内容是在itemtemplate中设置的,那么在这个过程中是否有任何特殊的顺序来阻止我更改它的背景

提前谢谢各位,
Kristo

设置属性直接优先于任何
设置程序
。与其直接设置属性,不如对
DockPanel
使用
样式
,并使用
设置器
设置背景,类似于在
数据触发器
中执行的操作。这将允许您在其他位置更改背景属性