Click here to Skip to main content
13,800,885 members
Rate this:
 
Please Sign up or sign in to 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 6-Dec-18 1:37am
Updated 6-Dec-18 2:45am

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web02 | 2.8.181215.1 | Last Updated 6 Dec 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100