This article will show you how to create a simple PanelBar.
Getting Started with RadPanelBar
Note |
|---|
In order to use RadPanelBar control in your projects you have to add references to the following assemblies:
- Telerik.Windows.Controls
- Telerik.Windows.Controls.Navigation
You can find more info here.
|
-
Drag and Drop the PanelBar control from the toolbox.
-
After you have dropped the control onto the XAML you can manage the control by setting various properties to operate the control's behavior:
CopyXAML
<telerik:RadPanelBar VerticalAlignment="Center" ExpandMode="Single" />
Populating the RadPanelBar with Items
Declaratively populating the RadPanelBar control Items collection
You can add RadPanelBarItems directly to the RadPanelBar.Items collection in XAML:
CopyXAML
<telerik:RadPanelBar>
<telerik:RadPanelBarItem Header="Item 1" />
<telerik:RadPanelBarItem Header="Item 2" />
<telerik:RadPanelBarItem Header="Item 3" />
</telerik:RadPanelBar>
Or you can populate the items collection from code-behind:
CopyC#
RadPanelBar myPanelBar = new RadPanelBar();
RadPanelBarItem item1 = new RadPanelBarItem() { Header = "Item 1" };
RadPanelBarItem item2 = new RadPanelBarItem() { Header = "Item 2" };
RadPanelBarItem item3 = new RadPanelBarItem() { Header = "Item 3" };
myPanelBar.Items.Add(item1);
myPanelBar.Items.Add(item2);
myPanelBar.Items.Add(item3);
Databinding the RadPanelBar control
The alternative to populating a RadPanelBar by explicitly declaring its items, is data binding the control to a collection of objects. Here is an example of binding a RadPanelBar to a list of strings:
CopyC#
List<string> myListDataSource = new List<string>();
myListDataSource.Add("Item 1");
myListDataSource.Add("Item 2");
myListDataSource.Add("Item 3");
RadPanelBar myPanel = new RadPanelBar();
myPanel.ItemsSource = myListDataSource;