如何摆脱数据网格单元格内容中的边框?
How to get rid of border in datagrid cell content?
我使用的是常规 WPF 数据网格。
我想去掉单元格中项目周围令人讨厌的边框。我应该使用哪个 属性 来删除它?
我实际上是在使用 celltemplate 在列中设置相同的行为。
[烦人的边框]https://i.ibb.co/ryxTfYB/anoyingborder.png
<DataGrid.Columns>
<DataGridTemplateColumn Header="Field" Width="130" >
<DataGridTemplateColumn.CellStyle>
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="KeyboardNavigation.IsTabStop" Value="False"/>
</Style>
</DataGridTemplateColumn.CellStyle>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox x:Name="FieldType" IsEditable="True"
ItemsSource="{Binding FieldTypeComboList, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"
DisplayMemberPath="Value"
SelectedItem="{Binding Type, Mode=TwoWay}"
VerticalAlignment="Center"
HorizontalContentAlignment="Center"
IsTextSearchEnabled="True"
MaxDropDownHeight="300">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel VirtualizingPanel.IsVirtualizing="True" IsItemsHost="True"/>
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
尝试在组合框上设置 BorderThickness="0"
并将组合框高度与单元格高度相匹配
Height="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGridCell}, Path=ActualHeight}"
我使用的是常规 WPF 数据网格。 我想去掉单元格中项目周围令人讨厌的边框。我应该使用哪个 属性 来删除它?
我实际上是在使用 celltemplate 在列中设置相同的行为。
[烦人的边框]https://i.ibb.co/ryxTfYB/anoyingborder.png
<DataGrid.Columns>
<DataGridTemplateColumn Header="Field" Width="130" >
<DataGridTemplateColumn.CellStyle>
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="KeyboardNavigation.IsTabStop" Value="False"/>
</Style>
</DataGridTemplateColumn.CellStyle>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox x:Name="FieldType" IsEditable="True"
ItemsSource="{Binding FieldTypeComboList, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"
DisplayMemberPath="Value"
SelectedItem="{Binding Type, Mode=TwoWay}"
VerticalAlignment="Center"
HorizontalContentAlignment="Center"
IsTextSearchEnabled="True"
MaxDropDownHeight="300">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel VirtualizingPanel.IsVirtualizing="True" IsItemsHost="True"/>
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
尝试在组合框上设置 BorderThickness="0"
并将组合框高度与单元格高度相匹配
Height="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGridCell}, Path=ActualHeight}"