C# 删除所有 DataGrid 行和单元格边框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8810771/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Removing all DataGrid row and cell borders
提问by diggingforfire
I want to hide (or remove) all the borders of all the rows (and subsequently cells) in my datagrid, think a basic HTML table. I've looked all over and most questions seem to be about styling them and not hiding them.
我想隐藏(或删除)我的数据网格中所有行(以及随后的单元格)的所有边框,想想一个基本的HTML 表。我已经看遍了,大多数问题似乎都是关于样式化而不是隐藏它们。
I've already tried setting the BorderBrush and BorderThickness like so:
我已经尝试过像这样设置 BorderBrush 和 BorderThickness:
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
</Style>
</DataGrid.RowStyle>
Tried the same for the CellStyle, but no dice, still seeing borders.
为 CellStyle 尝试了相同的方法,但没有骰子,仍然看到边框。
采纳答案by Adi Lester
What about setting GridLinesVisibility="None"?
设置GridLinesVisibility="None"呢?
<DataGrid GridLinesVisibility="None">
...
<DataGrid>
回答by Ramgy Borja
You could also do it this way
你也可以这样做
dataGrid.GridLinesVisibility = DataGridGridLinesVisibility.None;

