WPF Toolkit Datagrid Headers and Empty Source

2019-07-21 10:59发布

How could I make the Datagrid display the headers in case there's no row to display?

My Datagrid is "completely" read-only with:

"AutoGenerateColumns ="True" "CanUserAddRows="False" "CanUserDeleteRows="False" "CanUserResizeRows="False" "IsReadOnly"="True"

If there's no row, then the headers aren't displayed, if I add even an empty row, then the headers are shown!

Until now, I couldn't find any workaround/solution for that!

Thx all

Fred

3条回答
唯我独甜
2楼-- · 2019-07-21 11:25

I'm afraid there isn't, that's the way the wpf DataGrid was made (and I don't like that either...)

as for finding a particular row/cell, you can have a look there:

http://techiethings.blogspot.com/2010/05/get-wpf-datagrid-row-and-cell.html

be careful if you use virtualization though, as it might give you some trouble there.

查看更多
倾城 Initia
4楼-- · 2019-07-21 11:34

AFAIK If there are no rows then there are no columns and the column headers will not display. This is the same for the rows. If there are no rows then there are no row headers. This is by design and I think it is the way it should be.

Now to get your headers you could add an empty row and make it invisible? And remove this row when you add rows with content.

查看更多
登录 后发表回答