简体   繁体   English

根据单元格值的比较更改WPF DataGrid单元格字体

[英]Change WPF DataGrid Cell Font based on comparison of cell values

I am new to using the WPF DataGrid and I'm kind of lost. 我是使用WPF DataGrid的新手,我有点迷茫。 What I have is a DataTable with numeric values to which I bind the DataGrid via a DataView. 我有一个DataTable与数值,我通过DataView绑定DataGrid。 What I want to do is compare the values of each column, and make the cell that has the bigger value per column, bold. 我想要做的是比较每列的值,并使每列具有更大值的单元格为粗体。 (eg Who wins in each category) (例如,谁赢得每个类别)

There's no ObservableCollection, no fancy stuff. 没有ObservableCollection,没有花哨的东西。 I'm just adding data to a DataTable the "manual" way, getting the values cell-by-cell from an SQLite database DataTable response. 我只是以“手动”方式向DataTable添加数据,从SQLite数据库DataTable响应逐个单元获取值。 Even the columns are created programatically, and not via XAML. 甚至列都是以编程方式创建的,而不是通过XAML创建的。 I have almost no experience in XAML, so don't assume I've worked with Triggers or anything. 我几乎没有XAML的经验,所以不要以为我曾经使用过触发器或任何东西。

How would I go about doing something like this? 我该怎么做这样的事情?

Start from small examples. 从小例子开始。 You can create some test data, with which you can try data binding technique. 您可以创建一些测试数据,您可以使用它们尝试数据绑定技术。 Try to style some parts of DataGrid : change colors of Foreground , add some Border with BorderBrush . 尝试设置DataGrid某些部分:更改Foreground颜色,使用BorderBrush添加一些Border Explore WPF yourself - it is hard only for the first view. 自己探索WPF - 仅对第一个视图很难。

Here is some how to: 以下是一些如何:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM