Telerik RadDataPager, how to add pagesize field in pager

381 Views Asked by At

I am trying to implement raddatapager in my wpf application. Everything seems to be working fine except for the pagesize field. I can get the pagesize field in my page. It's showing other stuff like total pages, next previous button but not the pagesize field. i want to give an option to the user to change the pagesize from pager. I find something like this https://demos.telerik.com/aspnet-ajax/listview/examples/paging/pagingwithraddatapager/defaultcs.aspx but in wpf application.

Here is my code:

  <telerik:RadDataPager x:Name="radDataPager" 
           Source="{Binding DataList}" 
           Grid.Row="3" 
           Grid.Column="1"
           DisplayMode="All"                           
           PageSize="20" />
2

There are 2 best solutions below

0
zaphod-ii On

It seems that there is no built-in UI for this tasks, but it should be achievable with slight modification of the template. I tried this and it seems to be working fine.

<Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type telerik:RadDataPager}">
                    <Grid>
                        <DataPager:DataPagerPresenter AutoEllipsisMode="{TemplateBinding AutoEllipsisMode}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" DisplayMode="{TemplateBinding DisplayMode}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" ItemCount="{Binding ItemCount, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" NumericButtonStyle="{TemplateBinding NumericButtonStyle}" NumericButtonCount="{TemplateBinding NumericButtonCount}" PageCount="{TemplateBinding PageCount}" PageSize="{Binding PageSize, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" PageIndex="{TemplateBinding PageIndex}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
                        <StackPanel Orientation="Horizontal" Margin="0 0 120 0" HorizontalAlignment="Right">
                            <TextBlock Text="Page Size:" VerticalAlignment="Center"/>
                            <TextBox Height="20" Width="20"
                            Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=TwoWay, Path=PageSize}" />
                        </StackPanel>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>

Slight placement modifications might be needed to adapt it to your needs.

0
Martin Ivanov On

There is no built-in UI for the PageSize. However, there is a runnable project and a help article in the Telerik's resources that show how to achieve this. Basically, you can modify the default ControlTemplate of the DataPagerPresenter element.