views:

77

answers:

1

Silverlight windows phone 7. Listbox with selectionmode multiple.

How to make certain items selected by default. listbx.SelectedItems seems to have only get method.

A: 

You have to use SelectionMode as Extended XAML:

<ListBox x:Name="listBox" SelectionMode="Extended">
    <ListBoxItem>First</ListBoxItem>
    <ListBoxItem>Second</ListBoxItem>
    <ListBoxItem>Third</ListBoxItem>
    <ListBoxItem>Fourth</ListBoxItem>
</ListBox>

C#:

        this.listBox.SelectedItems.Add(this.listBox.Items[1]);
        this.listBox.SelectedItems.Add(this.listBox.Items[2]);

HTH

Avatar
Thanks ..this is helping me.
async
Glad to know :)
Avatar