Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
938 views
in Technique[技术] by (71.8m points)

wpf - DataGrid row virtualization display issue

We currently have a DataGrid that is bound to a DataTable. It also has a template column with a CheckBox in it that we add in programatically. This purpose of this column is track multiple selections in the DataGrid.

A factory is used to create the CheckBoxes for each row.

There are quite a few records, so row virtualization is set to true so that the performance is acceptable. However, we're seeing a strange issue where if we check some CheckBoxes on the first 10 rows and then scroll down about 50 rows (the grid has about 10 rows visible at any one time), there are a bunch of other CheckBoxes that appear to be checked at random.

If we disable row virtualization this problem does not exist (but the performance is terrible). Is there any way around this? Anyone know what we may be doing wrong?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you are looking for speed ListView Gridview is much much faster (and has less features).

Try disable container recycling.

             <tk:DataGrid x:Name="dataGrid" 
             ItemsSource="{Binding Path=Bookings}" 
             AutoGenerateColumns="False" 
             EnableRowVirtualization="True" 
             EnableColumnVirtualization="True"
             VirtualizingStackPanel.VirtualizationMode="Standard"
             VirtualizingStackPanel.IsVirtualizing="True">

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...