Getting Started with Silverlight ListBox

This tutorial will walk you through the required steps for using RadListBox.

Assembly References

In order to use RadListBox in your project you have to add the following assembly:

  • Telerik.Windows.Controls.dll

You can include the control in your page by either dragging it from the toolbox in Visual Studio, or manually creating the control. Below is an example of how to create the RadListBox control in XAML code:

Adding RadListBox to the Project

Example 1: Adding RadListBox

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

Populating with Items

The control can either be populated by adding RadListBoxItems to its Items collection, or by its data binding support.

Example 2: Adding RadListBoxItems

<telerik:RadListBox  Width="200" x:Name="radListBox"> 
    <telerik:RadListBoxItem Content="Australia" /> 
    <telerik:RadListBoxItem Content="Brazil" /> 
    <telerik:RadListBoxItem Content="Canada" /> 
    <telerik:RadListBoxItem Content="China" /> 
    <telerik:RadListBoxItem Content="England" /> 
    <telerik:RadListBoxItem Content="Germany" /> 
</telerik:RadListBox> 

Example 3: Binding RadListBox

<telerik:RadListBox x:Name="radListBox" Width="200"  
                    ItemsSource="{Binding Items}"/> 

More detailed information on how to populate RadListBox with some data you can found here.

Setting a Theme

The controls from our suite support different themes. You can see how to apply a theme different than the default one in the Setting a Theme help article.

Changing the theme using implicit styles will affect all controls that have styles defined in the merged resource dictionaries. This is applicable only for the controls in the scope in which the resources are merged.

To change the theme, you can follow the steps below:

  • Choose between the themes and add reference to the corresponding theme assembly (ex: Telerik.Windows.Themes.Fluent.dll). You can see the different themes applied in the Theming examples from our Silverlight Controls Examples application.

  • Merge the ResourceDictionaries with the namespace required for the controls that you are using from the theme assembly. For RadListBox, you will need to merge the following resources:

    • Telerik.Windows.Controls

Example 3 demonstrates how to merge the ResourceDictionaries so that they are applied globally for the entire application.

Example 3: Merge the ResourceDictionaries

<Application.Resources> 
    <ResourceDictionary> 
        <ResourceDictionary.MergedDictionaries> 
            <ResourceDictionary Source="/Telerik.Windows.Themes.Fluent;component/Themes/System.Windows.xaml"/> 
            <ResourceDictionary Source="/Telerik.Windows.Themes.Fluent;component/Themes/Telerik.Windows.Controls.xaml"/>                 
        </ResourceDictionary.MergedDictionaries> 
    </ResourceDictionary> 
</Application.Resources> 

Figure 4 shows RadMap with the Fluent theme applied.

Figure 4: RadListBox with the Fluent theme

Telerik Silverlight ListBox-fluent

See Also

In this article