New to Telerik UI for WPF? Download free 30-day trial

Data Binding

This article demonstrates how to bind the RadTabbedWindow control to a collection of business objects.

For the purposes of this example the control is bound to a collection of Tab objects. Please note that the class inherits from ViewModelBase which is the Telerik implementation of the INotifyPropertyChanged interface.

Example 1: The Tab class

public class Tab : ViewModelBase 
    private string header; 
    private string content; 
    public string Header 
        get { return this.header; } 
            if (value != this.header) 
                this.header = value; 
    public string Content 
        get { return this.content; } 
            if (value != this.content) 
                this.content = value; 
The next step is to create an ObservableCollection of Tab objects in your viewmodel.

Example 2: Create an ObservableCollection in the viewmodel

public class TabbedWindowViewModel : ViewModelBase 
    private ObservableCollection<Tab> tabs; 
    public ObservableCollection<Tab> Tabs 
            if (this.tabs == null) 
                this.tabs = new ObservableCollection<Tab>(); 
                this.tabs.Add(new Tab() { Header = "Progress", Content = "Progress Content" }); 
                this.tabs.Add(new Tab() { Header = "Microsoft", Content = "Microsoft Content" }); 
                this.tabs.Add(new Tab() { Header = "Google", Content = "Google Content" }); 
            return this.tabs; 
All that's left is to bind this collection to the RadTabbedWindow control. You also need to define the DisplayMemberPath and ContentTemplate properties so that the tabs appear as expected.

Example 3: Bind the ItemsSource property

<telerik:RadTabbedWindow x:Class="DataBinding.TabbedWindow" 
            ItemsSource="{Binding Tabs}"> 
        <local:TabbedWindowViewModel /> 
            <TextBlock Text="{Binding Content}" /> 

As of R2 2019 SP1 the control's Items property (populated when setting the control's ItemsSource) is of type IList. Prior to this version of the controls, it was of type ObservableCollection.

Please note that you need to replace the DataBinding namespace with your namespace.

Upon running the application, your RadTabbedWindow will now be populated with tabs as shown on Figure 1.

Figure 1: DataBound RadTabbedWindow

DataBound RadTabbedWindow

See Also

In this article
Not finding the help you need? Improve this article