This is a migrated thread and some comments may be shown as answers.

Navigate to specific page from code behind

4 Answers 140 Views
Book
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 15 Feb 2011, 05:09 PM
Hi,
Is there a way to navigate a book to a specific page from code behind?  I want to create a table of content besides the book that the user could also use for navigation just like the attached image
Thanks,
Paul

4 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 18 Feb 2011, 01:47 PM
Hello Paul,

A possible approach could be seen in this demo. You can examine its code. The table of contents is realized with RadTreeView and basically it uses the Tag property for navigation. Feel free to ask if you need more info on this.

Greetings,
Petar Mladenov
the Telerik team
0
Paul
Top achievements
Rank 1
answered on 18 Feb 2011, 02:01 PM
Hi Petar,

That seems like a good approach.  Can you elaborate on the use of the TAG property.  I do no see any method in the RadBook that permits navigation using the Tag property (i.e.: something like myBook.GoToTag("mytag")).

Paul
0
Accepted
Petar Mladenov
Telerik team
answered on 18 Feb 2011, 03:35 PM
Hi Paul,

You can examine the source code of the example by clicking the "ViewCode" button.
In the XAML part of the application you can see that different RadTreeViewItems that specify the contents of the book, have their Tag property set:
<telerik:RadTreeView Margin="25,45,25,0" x:Name="RadTreeView1">
                    <telerik:RadTreeViewItem Tag="4" Header="UI Components"
                            IsExpanded="True">
                        <telerik:RadTreeViewItem Cursor="Hand"
                                DefaultImageSrc="../Images/Book/Icons/aspnet.png" Header="ASP.NET Ajax" />
                        <telerik:RadTreeViewItem Cursor="Hand"
                                DefaultImageSrc="../Images/Book/Icons/Sl.png" Header="Silverlight" />
                        <telerik:RadTreeViewItem Cursor="Hand"
                                DefaultImageSrc="../Images/Book/Icons/mvc.png" Header="ASP.NET MVC" />
                        <telerik:RadTreeViewItem Cursor="Hand"
                                DefaultImageSrc="../Images/Book/Icons/winforms.png" Header="Winforms" />
                        <telerik:RadTreeViewItem Cursor="Hand"
                                DefaultImageSrc="../Images/Book/Icons/wpf.png" Header="WPF" />
                    </telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem Header="Data" Tag="6" IsExpanded="True">
                        <telerik:RadTreeViewItem Cursor="Hand"
Then, in code behind , we parse the Tag into int (pageindex) and navigate to the Page corresponding to the parsed pageindex:
void RadTreeViewItem_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if (this.foldActivated)
            {
                return;
            }
  
            RadTreeViewItem item = (e.OriginalSource as FrameworkElement).ParentOfType<RadTreeViewItem>();
            if (item == null) return;
  
            object tag = (item.Parent as FrameworkElement).Tag;
            if (tag == null) return;
  
            int pageIndex = Int16.Parse(tag.ToString());
            if (pageIndex > 0)
            {
                RadBook1.RightPageIndex = pageIndex;
            }
        }
Hope this has helped you.

Greetings,
Petar Mladenov
the Telerik team
0
Paul
Top achievements
Rank 1
answered on 18 Feb 2011, 03:41 PM
Hi Petar,
Yes, that helps.
Thanks,
Paul
Tags
Book
Asked by
Paul
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Paul
Top achievements
Rank 1
Share this question
or