Object instantiation
Note |
|---|
In order to use RadToolBar you need to add reference to the following assemblies in your project: - Telerik.Windows.Controls
- Telerik.Windows.Controls.Navigation
You can find more info here. |
CopyC#
using Telerik.Windows.Controls;
RadToolBar toolBar = new RadToolBar();
CopyXAML
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
<telerik:RadToolBar />
Adding Items
CopyC#
using Telerik.Windows.Controls;
RadToolBar toolBar = new RadToolBar();
Button button = new Button(){ Content="Button" };
toolBar.Items.Add(button);
CopyXAML
xmlns:telerik=http://schemas.telerik.com/2008/xaml/presentation
<telerik:RadToolBar>
<Button Content="Button" />
</telerik:RadToolBar>
Overflow Mode
The OverflowMode Attached Property determines whether the items are distributed among Strip and Overflow areas. Possible values are:
- OverflowMode.Never: item will be placed only in the Strip panel;
- OverflowMode.Always: item will be placed only in the Overflow panel;
- OverflowMode.AsNeeded: item’s location depends on the available space in the Strip panel;
Note |
|---|
There are corresponding methods GetOverflowMode and SetOverflowMode to access the OverflowMode property for the specified element. |
CopyC#
using Telerik.Windows.Controls;
RadToolBar toolBar = new RadToolBar();
this.LayoutRoot.Children.Add(toolBar);
Button button = new Button(){ Content="Button" };
toolBar.Items.Add(button);
RadToolBar.SetOverflowMode(button, OverflowMode.Never);
OverflowMode om = RadToolBar.GetOverflowMode(toolBar);
CopyXAML
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
<telerik:RadToolBar>
<Button Content="Button" telerik:RadToolBar.OverflowMode="Always"/>
</telerik:RadToolBar>
ItemsSource
Following standards for ItemsControls the tollbar’s items can be generated via ItemsSource.
CopyC#
using Telerik.Windows.Controls;
RadToolBar toolBar = new RadToolBar();
this.LayoutRoot.Children.Add(toolBar);
toolBar.ItemsSource = new List<object>()
{
new CheckBox() { IsChecked = true, Content = "Check box"},
new Button() { Content = "Button"},
new Image() { Source = new BitmapImage(new Uri("Images/image.png", UriKind.RelativeOrAbsolute))}
};
CopyXAML
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
<telerik:RadToolBar ItemsSource="{Binding Source={StaticResource MyToolBarItemsCollection}}" />
Band
Dependency property.
Gets or sets a value that indicates in which Band the RadToolBarTray will layout the toolbar.
BandIndex
Dependency property.
Gets or sets a value that indicates at which position in selected Band the RadToolBarTray will layout the toolbar.
Code:
CopyC#
using Telerik.Windows.Controls;
RadToolBarTray toolBarTray = new RadToolBarTray();
RadToolBar toolBar = new RadToolBar();
this.LayoutRoot.Children.Add(toolBarTray);
toolBarTray.Items.Add(toolBar);
toolBar.Band = 0;
toolBar.BandIndex = 3;
CopyXAML
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
<telerik:RadToolBarTray>
<telerik:RadToolBar Band="0" BandIndex="0" />
<telerik:RadToolBar Band="0" BandIndex="1" />
<telerik:RadToolBar Band="1" BandIndex="0" />
</telerik:RadToolBarTray>
Preview: