Programmatic Select All Feature

2 posts, 0 answers
  1. Edward
    Edward avatar
    5 posts
    Member since:
    Oct 2010

    Posted 27 Jul 2012 Link to this post

    On the RadListBox Control, can all items be programmatically selected in xaml or code-behind. And also, can all items be unselected programmatically in xaml or code-behind?
  2. Vladi
    Vladi avatar
    743 posts

    Posted 30 Jul 2012 Link to this post

    Hi Edward,

    In order to select all of the ListBox control items you should use the SelectAllCommand command in the Loaded event of the control. the next code snippet represents the described approach:

    In XAML:
    <telerik:RadListBox SelectionMode="Multiple" Loaded="RadListBox_Loaded" />

    In the code behind:
    private void RadListBox_Loaded(object sender, RoutedEventArgs e)
        RadListBox.SelectAllCommand.Execute(null, sender as RadListBox);

    If you want to select all the items of RadListBox without using the code behind you should make an attached property and attach it to the control.

    On your second question, to deselect all items you can use the SelectedItems.Clear() method. Here is a sample code snippet showing that:

    Hope this is helpful.

    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft R3 2016 release webinar banner
Back to Top