WPF 和网格中的图形?

发布于 2025-01-08 00:35:50 字数 219 浏览 2 评论 0 原文

我想在 WPF (C#) 的网格列中绘制类似折线图的图形。

像这样的东西:

在此处输入图像描述

显然,为了使其看起来不错,我需要将网格样式设置为没有单元格边框,但这不是问题。问题是我该如何处理这个问题?没有听起来不错的列类型,并且由于图形都是连接的,所以实现起来感觉很痛苦。

I would like to draw a linechart-like graph in a grid column in WPF (C#).

Something like this:

enter image description here

Obviously to make it look good I need to style the grid to not have cell borders, but that's not a problem. The problem is how would I even approach this? There's no column type that sounds good and since the graph is all connected it feels like painful to implement.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ㄟ。诗瑗 2025-01-15 00:35:50

不太确定为什么需要 Grid 控件,实际上在这里。也许 ListView 对您来说就足够了?它比网格控件轻量得多。

要绘制这些内容,您可以

  • 使用装饰器,以便在物品上绘制半透明的东西。

  • 为控件定义样式(ListViewGrid),其中左侧有与控件的项目集合重叠的 Canvas 元素。

或者

  • 可以尝试使用非常可定制的TreeControl,例如示例来自 Josh Smith,但自然会随着您的更改而变化。

祝你好运。

Not very sure why you need Grid control, actually here. May be ListView would enough for you ? It's much more lightweight then Grid control.

To draw that stuff you could

  • make use of Adorners in order to draw something semitransparent over the items.

or

  • Define a style for the control (ListView or Grid) where on left side you have Canvas element which overlaps the items collection of the control.

or

  • can try to use very customizable TreeControl like from example from Josh Smith, but naturally with your changes.

Good luck.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文