WPF DataGrid相对于数据交替显示行颜色

编程入门 行业动态 更新时间:2024-10-28 21:27:28
本文介绍了WPF DataGrid相对于数据交替显示行颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好! 我希望这是一个简单的方法,但是我对WPF还是很陌生,所以我还没有找到答案. 问题出在这里:我得到了一个简单的WPF Datagrid(.Net 4.0),用于存储按日期排序的报告.我希望同一天的数据网格中的所有条目都使用一种颜色,并在另一天与另一种颜色交替使用. 举例来说,所有成对的天数线必须为红色,而另一对为绿色.

Hi everybody ! I hoped this one was a simple one, but I''m quite new to WPF, so I didn''t found an answer yet. Here is the problem :I got a simple WPF Datagrid (.Net 4.0) storing reports, sorted by date. I want all the entries in the datagrid of the same day to be in one color, and alternate with another one for the other day. Let''s say for exemple, that all pair days number lines have to be red, and the other green. The

AlternatingRowBackground

属性仅交替显示每一行,在这种情况下,我看不到如何使用

property only alternates every line, and I don''t see how I could use

AlternatingCount

... 而且,我实际上在网格中有一个日期"列. 我认为这与模板或触发器有关,对吗? 预先感谢您的帮助!

in this context... And, i actually got a "Date" column in the Grid. I think it has something to do with templates or triggers, am I right ? Thanks in advance for your help !

推荐答案

有些事情在后面的代码中容易完成.您可以在数据网格上设置LoadingRow事件.然后,在事件中,根据所需条件设置行背景. 祝你好运 Some things are much easier done in code behind. You can set up a LoadingRow event on your data grid. Then, in the event, set the row background based on whatever criteria you want. Good Luck

更多推荐

WPF DataGrid相对于数据交替显示行颜色

本文发布于:2023-10-19 15:14:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1507905.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:相对于   颜色   数据   WPF   DataGrid

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!