我怎样才能得到一个网格绘制边框空白单元格? [英] How can I get a Grid to draw Borders for blank cells?
问题描述
我有一个ItemsControl,它使用 Grid
作为 ItemsPanelTemplate
,并设置Grid.Column和Grid。将行放在 ItemContainerStyle
中以将数据项放入网格中
有没有办法将GridLines添加到网格,或者用边框填充空白单元格?
现在我已将 ShowGridLines
设置为True,虚线,但是我想水平线显示出来,我更喜欢实体GridLines
这里有一个相当大量的XAML,但这里是我的XAML布局的截图:
很抱歉,无法完成网格线的样式设计。至少不是一个简单的方法。请参阅以下问题以获取解释:如何更改WPF中网格的网格线的颜色?
MSDN文档说仅限于虚线是可用的,因为这个属性
是作为一个设计工具来调试布局问题,而不是用于生产质量代码的
如果你想在
a Grid内部的行,
编辑:请参阅以下链接:更改WPF Grid Control的网格线的颜色/粗细
这是一个从 Grid
派生的自定义控件,并绘制了 GridLines
在 OnRender
中。我试过了,它似乎工作得很好。像这样可用
< controls:GridControl ShowCustomGridLines =True
GridLineBrush =Red
GridLineThickness = 1 >
< Grid.RowDefinitions>
< RowDefinition />
< RowDefinition />
< RowDefinition />
< /Grid.RowDefinitions>
< Grid.ColumnDefinitions>
< ColumnDefinition />
< ColumnDefinition />
< ColumnDefinition />
< /Grid.ColumnDefinitions>
< / controls:GridControl>
I have an ItemsControl which uses a Grid
as the ItemsPanelTemplate
, and sets the Grid.Column and Grid.Row on the ItemContainerStyle
to position data items in the grid
Is there a way to either add GridLines to the Grid, or to fill in the blank cells with a Border?
Right now I have ShowGridLines
set to True which makes the dotted lines, however I want Horizontal lines to show up, and I'd prefer solid GridLines
There is a rather large amount of XAML, but here's a screenshot of how my XAML is laid out:
Sorry, styling the grid lines can't be done. Atleast not in an easy way. See the following question for an explanation: How can I change the color of the gridlines of a Grid in WPF?
MSDN docs say "Only dotted lines are available because this property is intended as a design tool to debug layout problems and is not intended for use in production quality code. If you want lines inside a Grid, style the elements within the Grid to have borders."
Edit: See the following link: Change Color / Thickness of Grid Lines for WPF Grid Control
It's a custom control that derives from Grid
and draws the GridLines
in OnRender
. I Tried it out and it seems to be working great. Useable like this
<controls:GridControl ShowCustomGridLines="True"
GridLineBrush="Red"
GridLineThickness="1">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
</controls:GridControl>
这篇关于我怎样才能得到一个网格绘制边框空白单元格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!