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

RightPageIndex acting strange

3 Answers 41 Views
Book
This is a migrated thread and some comments may be shown as answers.
Softwel
Top achievements
Rank 1
Softwel asked on 17 Oct 2012, 10:29 AM
Hi,

I'm trying to use the book to create a diary in which users can create 1 entry a day.
<telerik:RadBook Grid.Row="0" x:Name="book" ItemsSource="{Binding DagboekNotities}"
                                         LeftPageTemplate="{StaticResource LeftPageTemplate}"
                                         RightPageTemplate="{StaticResource RightPageTemplate}"
                                         FirstPagePosition="Left" IsKeyboardNavigationEnabled="True" Margin="2" />

The itemsSource is defined as follows:
Private _dagboekNotities As New ObservableCollection(Of DagboekNotitieVoorsteller)
Public Property DagboekNotities() As ObservableCollection(Of DagboekNotitieVoorsteller)
    Get
        Return _dagboekNotities
    End Get
    Set(ByVal value As ObservableCollection(Of DagboekNotitieVoorsteller))
        _dagboekNotities = value
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs("DagboekNotities"))
    End Set
End Property

This collection contains 1 object a day for a period that the user selects.
If there's an odd number of items in the collection, i.e. 3 objects, then the last page is a leftpage.

I expect the book to contain the following pages:
Page1 (left) : (rightpageindex - 1) = 0
Page2 (right): rightpageindex = 1
Page3 (left): rightpageindex = 2

However, after I browse to the last page, something happens to the rightpageindex and it becomes:
Page1 (left) : (rightpageindex - 1) = -1
Page2 (right) : rightpageindex = 0
Page3 (left) : rightpageindex = 2

Am I doing something wrong?












 

3 Answers, 1 is accepted

Sort by
0
Vladislav
Telerik team
answered on 19 Oct 2012, 08:16 AM
Hi Wim,

Thank you for this report.
This is actually an issue in the RadBook control. I have logged it here, where you can track its status and vote for it. The problem is caused by using the keyboard for navigating the RadBook control. If only the mouse is used for navigation - the RightPageTemplate is correct.
Thus, as a workaround for your scenario, you could disable the KeyboardNavigation and the RightPageIndex should work correctly if your application logic permits it. 

Your Telerik points are updated according this report.

Kind regards,
Vladislav
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Softwel
Top achievements
Rank 1
answered on 19 Oct 2012, 10:54 AM
Thank you for your fast response.

You are right. If only the mouse is used for navigation, all is correct.
I  removed the IsKeyBoardNavigationEnabled property in the XALM-definition.

But I'm mainly using a RadDataPager for navigation, and there the issue also appears.
Do you know any workaround for this?
<telerik:RadDataPager x:Name="radDataPager1"  Grid.Row="1" Grid.Column="0" Margin="0 0 0 5"
        HorizontalAlignment="Stretch" HorizontalContentAlignment="Center"
         Source="{Binding Path=PagedItems, ElementName=book}"
     DisplayMode="FirstLastPreviousNextNumeric"   AutoEllipsisMode="Both"
     NumericButtonCount="10"/>

Also, it's not very clear to me on how I can correctly display the pageindex of the last left page, when the book contains an odd number of pages.
In my LeftPageTemplate, I have defined the following to display the pageindex:
<TextBlock  Text="{Binding ElementName=book, Path=RightPageIndex,
Converter={StaticResource RightToLeftPageIndexConverter}}" />


The converter uses following code:
Public Function Convert(value As Object, targetType As System.Type, parameter As Object, culture As  System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
    Dim leftPageIndex As Integer = DirectCast(value, Integer) - 1
    Return leftPageIndex
End Function

This returns the correct pageindex for all left pages, except for the last left page, since the rightpageindex is equal to the leftpageindex for the last page in case of odd number of elements in the collection.
Is there a way to display the correct left page number in this case?
0
Vladislav
Telerik team
answered on 22 Oct 2012, 12:23 PM
Hi Wim,

Please find a sample workaround for this problem in the attached project.
The main idea is that we alter the LeftPageIndex if the last page is a "Left" one and we assume that the RadBook control is data bound.

Please let us know if this workaround is applicable to your scenario.

All the best,
Vladislav
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Book
Asked by
Softwel
Top achievements
Rank 1
Answers by
Vladislav
Telerik team
Softwel
Top achievements
Rank 1
Share this question
or