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

Paging RadGridView

3 Answers 702 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Trump
Top achievements
Rank 1
Trump asked on 30 Mar 2018, 12:13 AM

By the document, we can bind the pager as below.

<Grid x:Name="LayoutRoot"
        Background="White">   
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <telerik:RadGridView x:Name="radGridView"
                         ItemsSource="{Binding Employees}"
                         AutoGenerateColumns="False">
        <telerik:RadGridView.Columns>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding CompanyName}" />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Title}" />
        </telerik:RadGridView.Columns>
    </telerik:RadGridView>
    <telerik:RadDataPager x:Name="radDataPager"
                          Source="{Binding Items, ElementName=radGridView}"
                          PageSize="5" />

The question is that I can't assign the element name of the RadGridView. So how to bind the element?

Thanks.

3 Answers, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 03 Apr 2018, 08:05 AM
Hello Trump,

You can replace the ElementName binding with a RelativeSource one or a Source one with x:Reference. Please note that the latter still requires the x:Name attribute to be set.

May I ask why you're unable to assign the x:Name of the RadGridView control? Please also share the exact layout of the controls at your end. Are the RadGridView and RadDataPager placed in the same parent control as is the case in the example you referenced? Based on this information I may be able to suggest a viable solution for your setup.

I look forward to your reply.

Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Trump
Top achievements
Rank 1
answered on 03 Apr 2018, 02:53 PM

The Rad controls are inside my customized usercontrol component. The control already has x:Name. So I can't assign the name.

The exact layout is something like.

<StackPanel>
      <Grid >Some TextBlocks</Grid>
      <telerik:RadGridView />
      <telerik:RadDataPager />
</StackPanel>

I think that is to binding sibling question. Just no clue.

Thanks

0
Trump
Top achievements
Rank 1
answered on 03 Apr 2018, 07:51 PM

I figured it out by https://stackoverflow.com/questions/18079385/how-can-i-bind-to-a-control-without-a-name-or-an-xname

And

https://www.telerik.com/forums/raddatapager-not-working

Resolved it!!!

Tags
General Discussions
Asked by
Trump
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Trump
Top achievements
Rank 1
Share this question
or