Skip to main content

Microsoft Silverlight

Answered Question Issue with Checkboxes selected themselves when inside a ListBox and scrolling quickly up and down by grabbing the sliderRSS Feed

(0)

LarryDev
LarryDev

Member

Member

28 points

35 Posts

Issue with Checkboxes selected themselves when inside a ListBox and scrolling quickly up and down by grabbing the slider

Hello.  I am trying to code a listbox in Silverlight 3 (released version) and am having issues with placing two checkboxes inside of a list.  I have created a simple example to demonstrate my issue.  In my example I create 50 rows of two checkboxes.  When I run the project I can check the 2nd and 3rd rows left checkboxes.  Then if I grab the listboxes scroll bar and scroll down to the bottom and back up again I am fine if I scroll slowly.  But if I grab the scroll bar and quickly go up and down or if I use the up and down arrows on the scroll bar I will find random other checkboxes selected.  Has anyone else run in to this issue and does anyone have a solution?  Thank You!

Here is my sample code:

MainPage.xaml

<UserControl x:Class="CheckBoxIssueCSharp.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
  <Grid x:Name="LayoutRoot">
        <ListBox x:Name="lstTest" Width="100" Height="200">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel x:Name="spTest" Orientation="Horizontal">
                        <CheckBox x:Name="chkOne"/>
                        <CheckBox x:Name="chkTwo"/>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</UserControl>

 MainPage.xaml.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace CheckBoxIssueCSharp
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            for (int n = 0; n <= 51; n++) { lstTest.Items.Add("");
            }
        }
    }
}

 

LarryDev
LarryDev

Member

Member

28 points

35 Posts

Answered Question

Re: Issue with Checkboxes selected themselves when inside a ListBox and scrolling quickly up and down by grabbing the slider

I was able to get an answer by posting to the Report a Bug Forum.  Please see my post on that forum if you are having this issue.

 http://silverlight.net/forums/p/114156/261300.aspx#261300

Thank you!

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities