Welcome to the Xceed Community | Help
Community Search  
More Search Options

How to retrieve the selected item(s)?

Sort Posts: Previous Next
  •  09-27-2011, 3:49 PM Post no. 31101

    How to retrieve the selected item(s)?

    I have a ListBox bound to an AsyncDataSourceProvider with data virtualization enabled. In the SelectionChanged event, the SelectedItem is null, the SelectedValue is null, and the SelectedItems is empty.

    I am aware of Marc's blog post explaining how to get the selected items from a virtualized DataGrid, but it doesn't work with the ListBox.

    How do I retrieve the selected item or items from the ListBox in this scenario?

  •  09-27-2011, 3:59 PM Post no. 31102 in reply to 31101

    Re: How to retrieve the selected item(s)?

    Never mind - I've just found it. Smile

    private void ListBox_SelectionChanged(object sender, EventArgs e)
    {
        var list = (Xceed.Silverlight.ListBox.ListBox)sender;
        list.BeginGetSelectedItems(ar =>
        {
            IEnumerable<object> items = list.EndGetSelectedItems(ar);
            // Use selection here...
        }, null);
    }
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.