This topic contains the following sections.
Define a RadBook control
Note |
|---|
In order to use the RadBook 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. |
RadBook is an ItemsControl. The pages of the book are represented by the RadBookItem control. RadBookItem is a ContentControl. Below is a basic declaration of RadBook with several pages:
CopyXAML
<UserControl x:Class="SilverlightApplication11.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
<Grid x:Name="LayoutRoot" Background="Purple">
<telerik:RadBook Margin="50">
<telerik:RadBookItem Background="Red">
<TextBlock Text="Page 1" FontSize="36"/>
</telerik:RadBookItem>
<telerik:RadBookItem Background="BlueViolet">
<TextBlock Text="Page 2" HorizontalAlignment="Right" FontSize="36"/>
</telerik:RadBookItem>
<telerik:RadBookItem Background="RosyBrown">
<TextBlock Text="Page 3" FontSize="36"/>
</telerik:RadBookItem>
<telerik:RadBookItem Background="Chocolate">
<TextBlock Text="Page 4" HorizontalAlignment="Right" FontSize="36"/>
</telerik:RadBookItem>
</telerik:RadBook>
</Grid>
</UserControl>This is the result of the above code:
Adding content to the pages of the Book
You can add any UIElement as a content of the pages. RadBookItem has a Content property which you can populate with a single root panel which contains the page content.
CopyXAML
<telerik:RadBook Margin="50">
<telerik:RadBookItem Background="Red">
<StackPanel>
<TextBlock Text="Page 1" FontSize="36"/>
<Button Content="Click Me"/>
</StackPanel>
</telerik:RadBookItem>
<telerik:RadBookItem Background="BlueViolet">
<StackPanel>
<TextBlock Text="Page 2" HorizontalAlignment="Right" FontSize="36"/>
<Image Source="Koala.jpg" Width="320" Height="240"/>
</StackPanel>
</telerik:RadBookItem>
<telerik:RadBookItem Background="RosyBrown">
<TextBlock Text="Page 3" FontSize="36"/>
</telerik:RadBookItem>
<telerik:RadBookItem Background="Chocolate">
<TextBlock Text="Page 4" HorizontalAlignment="Right" FontSize="36"/>
</telerik:RadBookItem>
</telerik:RadBook>
Setting the initial page
To set the initial page that will be displayed - set the RightPageIndex property:
CopyXAML
<telerik:RadBook Margin="50" x:Name="RadBook1" RightPageIndex="3">
<telerik:RadBookItem Background="Red">
<StackPanel>
<TextBlock Text="Page 1" FontSize="36"/>
<Button Content="Click Me"/>
</StackPanel>
</telerik:RadBookItem>
<telerik:RadBookItem Background="BlueViolet">
<StackPanel>
<TextBlock Text="Page 2" HorizontalAlignment="Right" FontSize="36"/>
<Image Source="Koala.jpg" Width="320" Height="240"/>
</StackPanel>
</telerik:RadBookItem>
<telerik:RadBookItem Background="RosyBrown">
<TextBlock Text="Page 3" FontSize="36"/>
</telerik:RadBookItem>
<telerik:RadBookItem Background="Chocolate">
<TextBlock Text="Page 4" HorizontalAlignment="Right" FontSize="36"/>
</telerik:RadBookItem>
</telerik:RadBook>
See Also