Wpf DataGridTemplateColumn内的组合框未拉伸以填充单元格

Wpf DataGridTemplateColumn内的组合框未拉伸以填充单元格,wpf,xaml,Wpf,Xaml,我有一个DataGrid,其模板列如下所示 <DataGridTemplateColumn Header="Doc Name"> <DataGridTemplateColumn.CellStyle> <Style TargetType="DataGridCell" BasedOn="{StaticResource MetroDataGridCell}"> <Setter Property="Verti

我有一个DataGrid,其模板列如下所示

   <DataGridTemplateColumn Header="Doc Name">
      <DataGridTemplateColumn.CellStyle>
        <Style TargetType="DataGridCell" BasedOn="{StaticResource MetroDataGridCell}">
          <Setter Property="VerticalAlignment" Value="Stretch"/>
          <Setter Property="HorizontalAlignment" Value="Stretch"/>
        </Style>
      </DataGridTemplateColumn.CellStyle>
        <DataGridTemplateColumn.CellTemplate>
           <DataTemplate>
              <ComboBox ItemsSource="{Binding ItemTypes}" Width="200" DisplayMemberPath="ItemTyp" SelectedItem="{Binding SelectedItemType}" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch"/>
           </DataTemplate>
         </DataGridTemplateColumn.CellTemplate>
       </DataGridTemplateColumn>

我不知道为什么我在顶部和右侧之间获得了空间。检查下面的图片

我怎样才能去掉这个多余的空间


编辑:删除BasedOn=“{StaticResource MetroDataGridCell}”后

有一个样式应用于您的组合框,您需要覆盖它以使其停止应用

尝试将其添加到数据模板:

<DataTemplate.Resources>
  <Style TargetType="ComboBox">
    <Setter Property="Margin" Value="0" />
  </Style>
</DataTemplate.Resources>

或者这也应该起作用:

<DataTemplate.Resources>
  <Style TargetType="ComboBox" />
</DataTemplate.Resources>


右侧的空格可能是由于组合框的硬编码宽度为200?不知道MetroDataGridCell样式中是什么,但请尝试将边距和填充设置为0。@J.H.我已尝试将边距和填充设置为0,但没有效果。甚至我也删除了MetroDataGridCell,得到了相同的结果。@J.H.也删除了宽度,得到了相同的结果。也许你有一个样式应用于组合框?尝试将其添加到数据模板: