开发者

Silverlight Listbox with multiple selection mode

开发者 https://www.devze.com 2023-01-18 01:53 出处:网络
Silverlight windows phone 7. Listbox with selectionmode multiple. How to make certain items selected b开发者_开发知识库y default.

Silverlight windows phone 7. Listbox with selectionmode multiple.

How to make certain items selected b开发者_开发知识库y default. listbx.SelectedItems seems to have only get method.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消