C# WPF如何使DataGridComboxColumn的背景与DataGridTextBoxColumn相同

C# WPF如何使DataGridComboxColumn的背景与DataGridTextBoxColumn相同,c#,wpf,styles,datagridcomboboxcolumn,C#,Wpf,Styles,Datagridcomboboxcolumn,我在datagrid中有一个datagridCombox列。 为了使组合框始终像组合框一样显示(单击或不单击) 组合框的实现如下所示 xmlns:dg=”http://schemas.microsoft.com/wpf/2008/toolkit" 现在的问题是datagridrow具有交替背景。 我希望datagridrow中的combobox与datagridrow中的textbox列使用相同的背景。此外,当选择datagridrow时,组合框应以与该行其余部分相同的颜色高亮显示。如何做到

我在datagrid中有一个datagridCombox列。 为了使组合框始终像组合框一样显示(单击或不单击) 组合框的实现如下所示

xmlns:dg=”http://schemas.microsoft.com/wpf/2008/toolkit"


现在的问题是datagridrow具有交替背景。 我希望datagridrow中的combobox与datagridrow中的textbox列使用相同的背景。此外,当选择datagridrow时,组合框应以与该行其余部分相同的颜色高亮显示。如何做到这一点?谢谢

<Style x:Key="DataGridCellStyle" TargetType="{x:Type dg:DataGridCell}">
    <Setter Property="ContextMenu" Value="{DynamicResource cellContextMenu}" />
</Style>
<Style x:Key="DataGridRowStyle"  TargetType="{x:Type dg:DataGridRow}">
    <Style.Triggers>
        <Trigger Property="AlternationIndex" Value="1" >
            <Setter Property="Background" Value="Beige" />
        </Trigger>
    </Style.Triggers>
    <Setter Property="Margin" Value="0 2 0 2" />            
</Style>
<Style x:Key="DataGridStyle" TargetType="{x:Type dg:DataGrid}">
    <Setter Property="AlternationCount" Value="2" />
    <Setter Property="RowStyle" Value="{StaticResource DataGridRowStyle}" />
    <Setter Property="CellStyle" Value="{StaticResource DataGridCellStyle}" />
</Style>


您可以尝试将
数据模板中的
组合框
背景
属性设置为
透明

很好,它可以工作。谢谢。我应该想试试这个。一定是老了。
<Style x:Key="DataGridCellStyle" TargetType="{x:Type dg:DataGridCell}">
    <Setter Property="ContextMenu" Value="{DynamicResource cellContextMenu}" />
</Style>
<Style x:Key="DataGridRowStyle"  TargetType="{x:Type dg:DataGridRow}">
    <Style.Triggers>
        <Trigger Property="AlternationIndex" Value="1" >
            <Setter Property="Background" Value="Beige" />
        </Trigger>
    </Style.Triggers>
    <Setter Property="Margin" Value="0 2 0 2" />            
</Style>
<Style x:Key="DataGridStyle" TargetType="{x:Type dg:DataGrid}">
    <Setter Property="AlternationCount" Value="2" />
    <Setter Property="RowStyle" Value="{StaticResource DataGridRowStyle}" />
    <Setter Property="CellStyle" Value="{StaticResource DataGridCellStyle}" />
</Style>