Won't Fix
Last Updated: 06 Mar 2024 17:02 by ADMIN
Stenly
Created on: 02 Feb 2024 08:37
Category: DataPager
Type: Bug Report
1
DataPager: The page TextBox element does not display all numbers if the page number when having many pages

Depending on the chosen theme, the page TextBox will not display all of the digits. This is inconvenient in scenarios where the RadDataPager has many pages.

To work this around, subscribe to the Loaded event of RadDataPager and retrieve the ScrollContentPresenter element with x:Name="PART_ScrollContentPresenter" using the ChildrenOfType extension method and set its Width property to the desired value and HorizontalAlignment property to Center.

private void radDataPager_Loaded(object sender, RoutedEventArgs e)
{
    RadDataPager radDataPager = (RadDataPager)sender;

    ScrollContentPresenter scrollContentPresenter = radDataPager
        .ChildrenOfType<ScrollContentPresenter>().FirstOrDefault(x => x.Name == "PART_ScrollContentPresenter");

    if (scrollContentPresenter != null )
    {
        scrollContentPresenter.Width = 45;
        scrollContentPresenter.HorizontalAlignment = HorizontalAlignment.Center;
    }
}

1 comment
ADMIN
Stenly
Posted on: 06 Mar 2024 17:02

The DataPagerTextBox element has a set Width property by design, which leads to the hiding of the digits. This decision was taken, in order for the textbox to have a fixed size and not change its size based on the input value. 

With this in mind, since having many pages is a valid scenario, the correct way to prevent this behavior is to utilize the TextBoxStyle property of the RadDataPager control. A Style that targets the DataPagerTextBox element can be created and its Width property can be set so that the observed behavior is not present.

The following code snippet shows the appropriate way of updating the Width property of the DataPagerTextBox:

xmlns:dataPager="clr-namespace:Telerik.Windows.Controls.Data.DataPager;assembly=Telerik.Windows.Controls.Data"

<Window.Resources>
<!--If NoXaml assemblies are used: BasedOn="{StaticResource DataPagerTextBoxStyle}"-->
    <Style x:Key="DataPagerTextBoxStyle" TargetType="dataPager:DataPagerTextBox" >
        <Setter Property="Width" Value="98"/>
    </Style>
</Window.Resources>
<Grid>
    <telerik:RadDataPager x:Name="radDataPager" TextBoxStyle="{StaticResource DataPagerTextBoxStyle}"/>
</Grid