[英]How to remove bottom border of the last row of DataGrid
正如您所看到的,數據網格中最后一行的底部邊界位於數據網格的邊界附近,使它看起來很難看。 我怎樣才能解決這個問題?
<DataGrid HeadersVisibility="Column"
ItemsSource="{Binding Path=DevLengths}"
AutoGenerateColumns="False"
CanUserAddRows="False"
CanUserDeleteRows="False"
CanUserReorderColumns="False"
CanUserResizeRows="False"
CanUserResizeColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Header="Size" Binding="{Binding Id}" IsReadOnly="True"/>
<DataGridTextColumn Header="Length of Splice" Binding="{Binding LengthOfSplice}"/>
<DataGridTextColumn Header="Length of Development" Binding="{Binding LengthOfDevelopment}"/>
<DataGridTextColumn Header="Ldh" Binding="{Binding Ldh}"/>
<DataGridTextColumn Header="Length of Hook" Binding="{Binding LengthOfHook}" Width="*">
<DataGridTextColumn.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="Margin" Value="0,0,-1,0"/>
</Style>
</DataGridTextColumn.CellStyle>
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
您可以為DataGrid
設置BorderThickness="1,1,1,0"
。 這將刪除底部邊框,並將頂部,左側,右側設置為默認值1。
因此,您的新代碼將是:
<DataGrid HeadersVisibility="Column"
ItemsSource="{Binding Path=DevLengths}"
AutoGenerateColumns="False"
CanUserAddRows="False"
CanUserDeleteRows="False"
CanUserReorderColumns="False"
CanUserResizeRows="False"
CanUserResizeColumns="False"
BorderThickness="1,1,1,0">
<DataGrid.Columns>
<DataGridTextColumn Header="Size" Binding="{Binding Id}" IsReadOnly="True"/>
<DataGridTextColumn Header="Length of Splice" Binding="{Binding LengthOfSplice}"/>
<DataGridTextColumn Header="Length of Development" Binding="{Binding LengthOfDevelopment}"/>
<DataGridTextColumn Header="Ldh" Binding="{Binding Ldh}"/>
<DataGridTextColumn Header="Length of Hook" Binding="{Binding LengthOfHook}" Width="*">
<DataGridTextColumn.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="Margin" Value="0,0,-1,0"/>
</Style>
</DataGridTextColumn.CellStyle>
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.