Ankit Jain
Ankit Jain

Reputation: 333

CheckedListBox in WPF

We are working on an application using the MVVM architectural style (WPF) and facing an issue. Before using WPF we have worked with WinForms and we used CheckedListBox. But now we are unable to find such control in WPF. We are also using Infragistic toolkit.

Please provide any kind of help. Any lead will be appreciable.enter image description here

Upvotes: 2

Views: 2902

Answers (1)

Frerk Morrin
Frerk Morrin

Reputation: 729

You can take a Listbox and give it a Template with a Checkbox in. Something like:

    <ListBox ItemsSource="{Binding MyItems}">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <CheckBox IsChecked="{Binding IsSelected}" Content="{Binding}" />
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>

This looks like this:

Checklistbox in WPF

Edit: The Items must have a Property "IsSelected" or you have to Wrap them in a SelectableItem helper class, which holds the original Item and a IsSelected Property.

Upvotes: 9

Related Questions