How to bind RadDataPager.PageSize to RadNumericUpDown.Value in code
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
. What i'm a missing?
EDIT
Thanks to Klinger i got it straight.SetBinding
wants the Static Definition of the DP, not a ref开发者_运维问答erence to the instance.
Binding b = new Binding("PageSize");
b.Mode = BindingMode.TwoWay;
b.Source = dataPager;
pageSizeSelector.SetBinding(RadNumericUpDown.ValueProperty, b);
Only dependency properties know how to handle binding expressions.
Take a look on the control documentation to see if the PageSize property is a dependency property.
精彩评论