We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

MVVM And CheckListBox

Hi,
I have followed the sample from the following post ...

http://www.syncfusion.com/forums/120688/Get-the-checked-items-of-a-CheckListBox

but I cannot find a way to add a SelectedItem in code and have the associated checkbox ticked as a result.

I added a button to the main window, with the following click event:

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ClassViewModel cvm = (ClassViewModel)DataContext;
            cvm.SelectedStudents.Add(cvm.Students[3]);
        }

When i click the button, the item gets added to the listbox as expected, BUT THE RESPECTIVE CHECKBOX REMAINS UNTICKED. Which is the problem!!

Please can you help? :0)

I have attached the project I am working with.

Attachment: CheckedListBox_Sample_1d74edd7.rar

1 Reply

VR Vijayalakshmi Roopkumar Syncfusion Team March 14, 2016 11:16 AM UTC

Hi James,

Thank you for using Syncfusion products,

We have modified the sample that tries to meet your requirement. In this sample, we have added the new items by setting its IsSelected property as true in the button click, so that the items gets added in the listbox and also respective checkbox gets checked. Please download the sample from the following location:

Sample:CheckedListBox_Sample

Regards,
Vijayalakshmi V.R.

Loader.
Live Chat Icon For mobile
Up arrow icon