RowVirtualization cause incorrect background color for rows

后端 未结 3 886
死守一世寂寞
死守一世寂寞 2020-12-06 22:33

I have a WPF application and there is a Datagrid in some pages. This datagrid needs to load 5000 rows at once (Pagination is not an option for me) and this takes ages. I set

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-06 23:05

    This may be a bit too late for you since you apparently found a working solution for you, but hopefully it can help others. I had a similar problem just now and after some googling found out that the reason for this behaviour is that the default value for VirtualizationMode is Recycling. This means that item containers are reused and thus the coloring of the background will stick even if the item that occupies the container after scrolling says it should not be colored.

    To solve this simply set the VirtualizationMode to Standard, like so:

    
    

    The containers will then be recreated and destroyed when you scroll, applying any changes you do in the LoadingRow event.

提交回复
热议问题