문제

I need to do the following with a DataGrid. E.g.

Col A       Col B
1           A           
2           B
3           C
4           D

For instance where Col A = 3. I then want to change the background cell.Background = some color where row 3 intersects Col B. I would be passing in the value for Col A and column name dynamically. I am returning the cell values from a DataTable where the DataGrid is bound to a defaultview of the DataTable. Col A is the unique key.

도움이 되었습니까?

해결책 2

Found a solution with a single line of code to pragmatically set the current cell based on the items and column index for anyone else who may be looking for a solution to this as well.

In the XAML ensure the SelectionUnit is set to cell. Then:

dg.CurrentCell = new DataGridCellInfo(dg.Items[0],dg.Columns[0]);

다른 팁

if you wanna change your cell style - use the cell style and Style.DataTrigger. you just have to make sure that the data you need is anywhere in the DataRow.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top