2016-07-18 57 views
0

正如您所看到的,數據網格中最後一行的底部邊框落在數據網格的邊框附近,並使其看起來很醜。我怎樣才能解決這個問題?如何刪除DataGrid的最後一行的底部邊框

enter image description here

<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> 

回答

1

您可以設置BorderThickness="1,1,1,0"爲您DataGrid。這將刪除底部邊框,並設置上,左,右的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> 
+0

太謝謝你了。這工作! – Vahid

+0

任何想法如何刪除所有行邊界? – Vahid

+1

根據要隱藏的部分,您可以將'GridLinesVisibility'(另一個'DataGrid'屬性)設置爲'All','Horizo​​ntal','None'或'Vertical'。 – Tone