Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I have created a Datagrid with 3 columns. One of the columns is a Checkbox. The checkbox is used to select the item in the Datagrid.

I have used the XAML code below to create the datagrid. There is no Code behind which interacts about checkin the checkbox. However, when i check checkboxes and i scroll down. Some of the Checkboxes i never checked become checked. Also, the checkboxes i checked randomly stay checked or uncheck. I have filmed the problem and uploaded it to youtube. You can find the link below. I have added subtitles to explain what is happening.

Anyone have a clue on why this keeps happening and how to stop it?

<DataGrid x:Name="Lbox" CanUserDeleteRows="False" Margin="10,86,519.333,-0.333"
                        ItemsSource="{Binding Items}" CanUserAddRows="false" AutoGenerateColumns="False">
                        <DataGrid.Columns>
                            <DataGridTemplateColumn Header="DUT">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <CheckBox x:Name="checkboxinstance"/>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTextColumn Binding="{Binding DraadNr}" Header="DraadNr" IsReadOnly="True"/>
                            <DataGridTextColumn Binding="{Binding Naam}" Header="Draadlijst" IsReadOnly="True" />
                        </DataGrid.Columns>
                    </DataGrid>


YouTube[^]

What I have tried:

I have googled the problem, but i could not find a problem which is nearly the same as mine.
Posted
Updated 6-Dec-18 1:45am

1 solution

This happens because of Data Virtualization, you can resolve it by applying the following code to your datagrid control
VirtualizingPanel.VirtualizationMode="Standard"

For more info on virtualization you can check this
link
 
Share this answer
 
Comments
Member 13947785 7-Dec-18 3:04am    
When i scroll down with the VirtualizationMode on Standard. Only the last checked checkbox will stay checked. The other uncheck

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900