New to Telerik UI for WPF? Download free 30-day trial

Allow Numbers Only in the PageIndex TextBox of RadDataPager


Product Version 2019.3.1023
Product RadDataPager for WPF


Allow entering only numeric input in the DataPagerTextBox that shows the current page index.


Subscribe to the Loaded event of RadDataPager in order to get the DataPagerTextBox control representing the page index input. Then subscribe to the PreviewTextInput event of DataPagerTextBox. In the handler, you can check the current Text and if there is a non-numeric value, set the Handled property of the event arguments to True. This will cancel the input.

private void RadDataPager_Loaded(object sender, RoutedEventArgs e) 
    var dataPagerTextBox = this.radDataPager.FindChildByType<DataPagerTextBox>(); 
    dataPagerTextBox.PreviewTextInput += Tb_PreviewTextInput; 
private void DataPagerTextBox_PreviewTextInput(object sender, TextCompositionEventArgs e) 
    Regex regex = new Regex("[^0-9]+"); 
    e.Handled = regex.IsMatch(e.Text); 
In this article