如何在数据网格中的某些项目之后显示网格线
我想根据一列值在某个项目之后绘制一条水平网格线。如果我说 GridLineVisibility="Horizontal",则显示所有线条。但我想仅当列中的某些值满足条件时才显示此行
例如这里是数据网格
Name ID
XYZ 1
ABC 2
WER 4
VGF 2
我想在ID = 2时显示网格线?我该怎么做?
I want to draw a horizontal grid line after certain item based on one column value.If I say GridLineVisibility="Horizontal", then all the lines are shown. but I want to show this line only when certain value in a column satisfies the condition
For example here is the datagrid
Name ID
XYZ 1
ABC 2
WER 4
VGF 2
I want to show the grid line if the ID=2? How can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为直接通过 API 是不可能的。以下是一些可能的想法:
您可以使用行详细信息来“绘制”线条,使其只有几个像素高吗?这需要您自己设置选择并防止用户更改它(不确定您的情况是否可以接受)。
更改为单元格模板,以在相关项目的底部显示深色区域。
修改DataGrid源代码并将您的功能直接添加到控件中。
切换到网格控件,但随后您会失去 DataGrid 的一些优秀功能。
如果#1 或#2 符合你的限制,我会做其中之一。
I don't think that is possible through the API directly. Here are some possible ideas:
Can you use the row details to 'draw' the line by making it just a few pixels high? It would require that you set the selection yourself and prevent the user from changing it (not sure if that's acceptable in your case).
Change to cell templates to show a dark area at the bottom for the item in question.
Modify the DataGrid source code and add your feature to the control directly.
Switch to a Grid control, but then you loose some of the nice features of the DataGrid.
I would do either #1 or #2 if they fit within your constraints.