我使用DataGrid来显示一些信息。但是,每一行的右列都显示一条与DataGrid边框不对齐的额外边框线。
我尝试将单元格BorderThickness设置为0,但右边框线仍然存在。样式xaml代码如下。
<!-- DataGrid Cell -->
<Style TargetType="{x:Type DataGridCell}" x:Key="RightCell">
<Setter Property="BorderThickness" Value="0 0 0 0"/>
</Style>
<!--Text Block-->
<Style TargetType="{x:Type TextBlock}" x:Key="RegularTextBlock">
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="FontSize" Value="{StaticResource FontSizeSuperSmall}" />
</Style>
UI xaml代码如下所示。
<!-- DataGrid -->
<DataGrid Grid.Column="0"
Margin="0,0,10,0"
x:Name="ResultDataGrid"
ItemsSource="{Binding ResultList, UpdateSourceTrigger=PropertyChanged}"
AutoGenerateColumns="False"
CanUserAddRows="False"
CanUserSortColumns="False"
CanUserDeleteRows="False"
CanUserReorderColumns="False"
GridLinesVisibility="All"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto"
HorizontalAlignment="Center"
RowHeaderWidth="0"
BorderBrush="{StaticResource CustomPureBlackBrush}"
BorderThickness="1"
Background="{StaticResource CustomPureWhiteBrush}">
<!-- Set Columns -->
<DataGrid.Columns>
<!-- First two columns have been deleted for simplicity.-->
<!-- Type Column-->
<DataGridTemplateColumn Header="Type" Width="*" IsReadOnly="True" HeaderStyle="
{StaticResource FlattenRightHeader}" CellStyle="{StaticResource RightCell}" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid>
<TextBlock Name="BuyTYpe" Text="test" Style="{StaticResource RegularTextBlock}" />
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
谁能给我给予点建议?谢谢.
1条答案
按热度按时间2q5ifsrm1#
我相信是网格线造成的。尝试关闭它们:
如果需要这些线条,可以使用样式。