【问题标题】:Remove the border from a selected cell in a row in datagrid从数据网格中一行中的选定单元格中删除边框
【发布时间】:2012-07-22 13:33:18
【问题描述】:

正如您在 Jesse Furher 周围的图片中看到的那样,是一条黑色边框线,我怎样才能删除所有单元格的这条线?

【问题讨论】:

  • 我的答案对你有用还是还在寻找其他东西?

标签: wpf xaml styles


【解决方案1】:

在您的 DataGrid 资源中添加此样式,选择边框将消失 -

<DataGrid>
  .
  .
  <DataGrid.Resources>
    <Style TargetType="DataGridCell">
      <Setter Property="BorderThickness" Value="0"/>
      <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
    </Style>
  </DataGrid.Resources>
  .
  .
</DataGrid>

【讨论】:

  • 没有效果 - 你可以忽略它。 BorderThickness 的二传手是成功的关键。
  • @pr)gg3r - FocusVisualStyle 是必需的,以防您通过 Tab 键放置焦点。在这种情况下,您会在单元格周围看到虚线边框。
  • 删除该边框时单元格会非常紧。如何再次增加间距?设置 PaddingMargin 没有帮助。
  • @LonelyPixel:对于每个DataGrid*Column,将ElementStyle 设置为&lt;Style TargetType="TextBlock"&gt;&lt;Setter Property="Padding" Value="2"/&gt;&lt;/Style&gt;(或其他)。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-11
  • 2012-05-03
  • 1970-01-01
  • 2012-11-24
相关资源
最近更新 更多