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

RadDatapager with dynamic PageSize, depending on the size of the window.

1 Answer 242 Views
DataPager
This is a migrated thread and some comments may be shown as answers.
LRScudeletti
Top achievements
Rank 1
LRScudeletti asked on 25 Nov 2014, 03:52 PM
I would remove the RadGridView scrollbars, I will use the RadDataPager to display only the amount of items that fit on the screen. But is not working. Any idea how to proceed? Sorry for my bad English.

My Code:

<Grid>
 
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition x:Name="rGridView"
                       Height="*" />
    </Grid.RowDefinitions>
 
    <telerik:RadDataPager PageSize="{Binding LinhasGridView, ElementName= ucCadastroCidade}"
                          Grid.Row="0"
                          Source="{Binding Items, ElementName=dtCidade}"
                          IsTotalItemCountFixed="True"
                          DisplayMode="FirstLastPreviousNextNumeric, Text" />
 
    <telerik:RadGridView x:Name="dtCidade"
                         Grid.Row="1"
                         AutoGenerateColumns="False"
                         ItemsSource="{Binding ListaCidade, ElementName= ucCadastroCidade}">
        <telerik:RadGridView.Columns>
            <telerik:GridViewDataColumn Width="*"
                                        Header="Cidade"
                                        DataMemberBinding="{Binding nm_Cidade}" />
            <telerik:GridViewDataColumn Width="*"
                                        Header="Estado"
                                        DataMemberBinding="{Binding UF.nm_Uf}" />
        </telerik:RadGridView.Columns>
    </telerik:RadGridView >
 
</Grid>


Here I do the calculation:

LinhasGridView = (double)(rGridView.ActualHeight / dtCidade.RowHeight);

Thank you!

1 Answer, 1 is accepted

Sort by
0
Boris
Telerik team
answered on 28 Nov 2014, 07:22 AM
Hello LRScudeletti,

A possible way to fulfill your requirement is to bind the PageSize property of the DataPager to e a property in your ViewModel. Then to update it you can use the SizeChanged event of RadGridView. In addition, I attached a sample project that demonstrates the suggested approach.

Please note that you will need to implement the INotifyPropertyChanged interface for your ViewModel.


I hope this helps.

Regards,
Boris
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
DataPager
Asked by
LRScudeletti
Top achievements
Rank 1
Answers by
Boris
Telerik team
Share this question
or