Book > C1Book Task-Based Help > Navigating the Book with Code |
You can set the displayed page using the C1Book.CurrentPage property, but you can also use the C1Book.TurnPage method to change the current page at run time. For more information, see Book Navigation. In this topic you'll add two buttons to your application, one that will turn to the previous page and one that will turn to the next page of the book.
To add additional navigation to your book, complete the following steps:
XAML Copy Code <Button HorizontalAlignment="Right" Margin="0,43,12,0" Name="Button1" Width="28" Height="23" VerticalAlignment="Top">></Button> <Button Height="23" HorizontalAlignment="Left" Margin="12,43,0,0" Name="Button2" VerticalAlignment="Top" Width="28"><</Button>
Colorized Example Code
Visual Basic Copy CodeImports C1.WPF
Imports C1.WPF.Extended
C# Copy Code using C1.WPF; using C1.WPF.Extended;
Visual Basic Copy Code Private Sub Button1_Click(ByVal sender as Object, ByVal e as System.Windows.RoutedEventArgs) Me.C1Book1.TurnPage(True) End Sub Private Sub Button2_Click(ByVal sender as Object, ByVal e as System.Windows.RoutedEventArgs) Me.C1Book1.TurnPage(False) End Sub
C# Copy Code public MainPage() { private void button1_Click(object sender, System.Windows.RoutedEventArgs e) { this.c1Book1.TurnPage(true); } private void button2_Click(object sender, System.Windows.RoutedEventArgs e) { this.c1Book1.TurnPage(false); }}
This code will turn the book a page forward or back depending on the button clicked.
What You've Accomplished
You've customized navigation in the book. To view the book's navigation, run the application and click the right button. Notice that the page turns to the next page with a page turning animation:
Click the left button and observe that the book returns to the previous page.