When we render any PDF file with 'x' number of page count and try to enter page 'x+1' in telerik:CurrentPageTextBox and hit enter, it will enable the Previous Page RadButton and if we click Previous Page then it will freeze the application.
System.ArgumentOutOfRangeException: 'pageNo should be greater or equal than 1 and less or equal than 4. (Parameter 'pageNo')'
Workaround: A possible approach could be to attach to the CurrentPageTextBox` KeyDown event in order to restrict the input.
XAML:
<telerik:CurrentPageTextBox x:Name="PART_CurrentPageNumberTextBox"
KeyDown="PART_CurrentPageNumberTextBox_KeyDown"
Text="{Binding FixedDocumentViewer.CurrentPageNumber, Mode=TwoWay}"/>
private void PART_CurrentPageNumberTextBox_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
TextBox textBox = sender as TextBox;
if (textBox != null)
{
if (e.Key == System.Windows.Input.Key.Enter)
{
int pagesCount = this.pdfViewer.PagesCount;
int currentPageNumber = this.pdfViewer.CurrentPageNumber;
if (this.pdfViewer.Document != null && (currentPageNumber < 1 || currentPageNumber > pagesCount))
{
RadFixedPage currentPage = this.pdfViewer.CurrentPage;
int pageNum = this.pdfViewer.Document.Pages.IndexOf(currentPage) + 1;
this.pdfViewer.CurrentPageNumber = pageNum;
}
}
}
}