In Code Behind

This tutorial will walk you through the common tasks of adding and removing RadListBoxItems programmatically.

Example 1: RadListBox without Items

<telerik:RadListBox x:Name="radListBox" Width="200">             
</telerik:RadListBox> 

Adding RadListBoxItems

In order to add items to a RadListBox, you can create new RadListBoxItems and add them to the Items collection of the control.

Example 2: Populating RadListBox with items from code-behind

public MainWindow() 
{ 
    InitializeComponent(); 
 
    var item1 = new RadListBoxItem() { Content = "Australia" }; 
    radListBox.Items.Add(item1); 
    var item2 = new RadListBoxItem() { Content = "Brazil" }; 
    radListBox.Items.Add(item2); 
} 

Figure 1: RadListBox populated in code

radlistbox populatingwithdata incodebehind

Removing RadListBoxItems

In order to remove a specific RadListBoxItem, you should remove it from the RadListBox's Items collection.

Example 3: Removing RadListBoxItems

private void RemoveFirstItem() 
{ 
    this.radListBox.Items.Remove(this.radListBox.Items[0]); 
} 

See Also

In this article