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

Bind DataPager and RadNumericUpDown in codebehind

4 Answers 98 Views
DataPager
This is a migrated thread and some comments may be shown as answers.
Martijn
Top achievements
Rank 1
Martijn asked on 16 Jul 2010, 09:46 PM

I have a RadGridView, a RadDataPager and a RadNumericUpDown all defined in code.

Now i want to bind the RadDataPager.PageSize to the RadNumericUpDown.Value so the pagesize of the pager is changeable via the RadNumericUpDown control.

Thus i try:

RadDataPager dataPager = new ...;
RadNumericUpDown pageSizeSelector = new ...;

Binding b = new Binding();
b
.Mode = BindingMode.TwoWay;
b
.Source = pageSizeSelector.Value;

pageSizeSelector
.SetBinding(dataPager.PageSize, b);

But this generates an error about the dataPager.PageSize not being a DependencyProperty.

I tried the other way around:

Binding b = new Binding();
b
.Mode = BindingMode.TwoWay;
b
.Source = dataPager.PageSize;

dataPager.SetBinding(pageSizeSelector.Value, b);
But that also generates an error about  pageSizeSelector.Value not being a DependencyProperty.

 What i'm a missing? Or why aren't those DPs?

Thanks in advance!

4 Answers, 1 is accepted

Sort by
0
Accepted
Yavor Georgiev
Telerik team
answered on 17 Jul 2010, 04:03 AM
Hello Martijn,

 You need to set the binding on an object in the following way:
dataPager.SetBinding(RadDataPager.PageSizeProperty, b);

Basically, the first argument of SetBinding is the DependencyProperty static field in the control's class. In this case it's the static PageSizeProperty field on the RadDataPager class, which corresponds to the PageSize property of the dataPager object.

Regards,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Martijn
Top achievements
Rank 1
answered on 17 Jul 2010, 07:58 AM
Thanks! I now see that i got my understanding of setbinding wrong. It needs the static defintion of a DP, not an instance reference.
0
Rossen Hristov
Telerik team
answered on 19 Jul 2010, 10:38 AM
Hello Martijn,

You see an example of a RadDataPager.PageSize bound to a NumericUpDown in this online example.

Greetings,
Ross
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Martijn
Top achievements
Rank 1
answered on 19 Jul 2010, 02:12 PM
Thanks, i was aware of that example. But i wanted it to be done in codebehind, not in XAML. 

I managed to get it done eventually (once i understood binding in code better).
Tags
DataPager
Asked by
Martijn
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Martijn
Top achievements
Rank 1
Rossen Hristov
Telerik team
Share this question
or