Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9254895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:35:18+00:00 2026-06-18T11:35:18+00:00

For that problem I made a minimal project for everyone to experience this behaviour.

  • 0

For that problem I made a minimal project for everyone to experience this behaviour. I hope it is not just on my engine running like this.

minimal project

In my project I realized a listbox with a a lot of sample data. The listbox has a checkbox element for each item as well.

The problem: First I check/uncheck checkboxes in my listbox. Then I scroll several times through my listbox. Now I notice that a lot of checkboxes get checked/unchecked randomly. If I cut the ListBox a bit down (see comments in source code) there is no strange behaviour. EDIT:: If you dont have this problem, try to check items at the very bottom of the list. Maybe you have to extend the list with some more objects to see the problem.

Here some code snippets. As you can see I already tried it with List/ObservableCollection, PropertyChanged and LongListSelector instead of Listbox.

C#

    // Already tried to use simple List<SampleCheckedData> buildings. 
    // Doesnt change anything.
    private ObservableCollection<SampleCheckedData> buildings;

    // Already tried with this as well.
    /*protected ObservableCollection<SampleCheckedData> Buildings
    {
        get
        {
            return buildings;
        }
        set
        {
            buildings = value;
        }
    }*/

    public MainPage()
    {
        InitializeComponent();

        buildings = new ObservableCollection<SampleCheckedData>();

        buildings.Add(new SampleCheckedData() { Name = "Cloudy", IsChecked = false });
        buildings.Add(new SampleCheckedData() { Name = "Sun", IsChecked = false });
        buildings.Add(new SampleCheckedData() { Name = "Drizzle", IsChecked = false });
        buildings.Add(new SampleCheckedData() { Name = "Snow", IsChecked = false });
        buildings.Add(new SampleCheckedData() { Name = "Cloudy", IsChecked = false });
        buildings.Add(new SampleCheckedData() { Name = "Sun", IsChecked = false });
        buildings.Add(new SampleCheckedData() { Name = "Drizzle", IsChecked = false });
        buildings.Add(new SampleCheckedData() { Name = "Snow", IsChecked = false });
        buildings.Add(new SampleCheckedData() { Name = "Cloudy", IsChecked = false });
        buildings.Add(new SampleCheckedData() { Name = "Sun", IsChecked = false });
        buildings.Add(new SampleCheckedData() { Name = "Cloudy", IsChecked = false });
        buildings.Add(new SampleCheckedData() { Name = "Sun", IsChecked = false });
        buildings.Add(new SampleCheckedData() { Name = "Drizzle", IsChecked = false });
        buildings.Add(new SampleCheckedData() { Name = "Snow", IsChecked = false });
        buildings.Add(new SampleCheckedData() { Name = "Cloudy", IsChecked = false });
        buildings.Add(new SampleCheckedData() { Name = "Sun", IsChecked = false });
        buildings.Add(new SampleCheckedData() { Name = "Cloudy", IsChecked = false });
        buildings.Add(new SampleCheckedData() { Name = "Sun", IsChecked = false });
        buildings.Add(new SampleCheckedData() { Name = "Drizzle", IsChecked = false });
        buildings.Add(new SampleCheckedData() { Name = "Snow", IsChecked = false });

        // If you comment this data out, the listbox is smaller and no problem occurs in my case.
        buildings.Add(new SampleCheckedData() { Name = "Cloudy" , IsChecked = false });
        buildings.Add(new SampleCheckedData() { Name = "Sun", IsChecked = false });
        buildings.Add(new SampleCheckedData() { Name = "Cloudy", IsChecked = false });
        buildings.Add(new SampleCheckedData() { Name = "Sun", IsChecked = false });
        buildings.Add(new SampleCheckedData() { Name = "Drizzle", IsChecked = false });
        buildings.Add(new SampleCheckedData() { Name = "Snow", IsChecked = false });
        // If you comment this data out, the listbox is smaller and no problem occurs in my case. [END]

        this.listBox2.ItemsSource = buildings;
    }

My check/uncheck events:

    private void CheckBox_Checked(object sender, RoutedEventArgs e)
    {
        //Use this if you use the LongListSelector.
        //ListBoxItem checedItem = this.listBox2.SelectedItem as ListBoxItem;

        ListBoxItem checedItem = this.listBox2.ItemContainerGenerator.ContainerFromItem((sender as CheckBox).DataContext) as ListBoxItem;
        if (checedItem != null)
        {
            checedItem.IsSelected = true;
        }
    }

    private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
    {
        //Use this if you use the LongListSelector.
        //ListBoxItem checedItem = this.listBox2.SelectedItem as ListBoxItem;

        ListBoxItem checedItem = this.listBox2.ItemContainerGenerator.ContainerFromItem((sender as CheckBox).DataContext) as ListBoxItem;
        if (checedItem != null)
        {
            checedItem.IsSelected = false;
        }
    }

And my smple data class:

public class SampleCheckedData
{
    //Already tried with this, but it is not working.

    /*
    private bool _isChecked;
    public bool IsChecked
    {
        get { return _isChecked; }
        set
        {
            if (_isChecked != value)
            {
                _isChecked = value;
                NotifyPropertyChanged("IsChecked");
            }
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;

    private void NotifyPropertyChanged(String info)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(info));
        }
    } 
    */

    public bool IsChecked
    {
        get;
        set;
    }

    public string Name
    {
        get;
        set;
    }
}

XAML

My content looks like this:

    <!--ContentPanel - zusätzliche Inhalte hier platzieren-->
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">

        <ListBox x:Name="listBox2" SelectionMode="Multiple">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <CheckBox IsChecked="{Binding IsChecked}" Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked"/>
                        <TextBlock Text="{Binding Name}" Width="150" VerticalAlignment="Center"/>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

        <!--//Use this if you use the LongListSelector.-->
        <!--<toolkit:LongListSelector  x:Name="listBox2"  Background="Transparent" IsFlatList="True"   ItemTemplate="{StaticResource citiesItemTemplate}" />-->

    </Grid>

Optional if you want to try it with LongListSelector include:

    <DataTemplate x:Key="citiesItemTemplate">
        <StackPanel Grid.Column="1"  VerticalAlignment="Top">
            <TextBlock Text="{Binding Name}" FontSize="26"  Margin="12,-12,12,6"/>
            <CheckBox IsChecked="{Binding IsChecked}" Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked"/>
        </StackPanel>
    </DataTemplate>

And xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"

I hope someone can solve this. Didnt find any clues…

EDIT:

Related problems:

One
Two
Three

EDIT:

I noticed that you have to add some mor eobjects in the list to have this problem:

    buildings.Add(new SampleCheckedData() { Name = "Cloudy", IsChecked = false });
    buildings.Add(new SampleCheckedData() { Name = "Sun", IsChecked = false });
    buildings.Add(new SampleCheckedData() { Name = "Cloudy", IsChecked = false });
    .....

Then, when you check items at the very top or bottom of the list, the problem occurs.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:35:20+00:00Added an answer on June 18, 2026 at 11:35 am

    You never save the selected state of the checkbox. Fix your XAML:

    <CheckBox IsChecked="{Binding IsChecked,Mode=TwoWay}" Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked"/>

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running ubuntu, 64bit. I have this minimal test package that i made to
I have a problem with a javascript set of functions that I made. This
This problem arose in a module I'm writing, but I have made a minimal
I've got a weird problem that i don't understand why it happened. I made
I have made a swings application but there is one problem in that which
Here's my problem: I have an unmanaged dll that I made.I'm calling one of
I know there's a lot of posts with the same that problem. I just
Today we faced a quite simple problem that were made even simpler by the
I made a very minimal javascript bookmarklet (~1 KB minified) that lets me play
I came across a problem that made no sense to me but was solved

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.