Completed
Last Updated: 18 Sep 2020 04:47 by ADMIN
Release LIB 2020.3.921 (09/21/2020)
Created by: Stefan
Comments: 1
Category: DataPager
Type: Bug Report
2

When using the Office2016Touch theme and the default control template, the following binding errors can be observed in Visual Studio output:

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.ContentPresenter', AncestorLevel='1''. BindingExpression:Path=(TextElement.Foreground); DataItem=null; target element is 'TextBlock' (Name=''); target property is 'Foreground' (type 'Brush')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.ContentPresenter', AncestorLevel='1''. BindingExpression:Path=(TextElement.Foreground); DataItem=null; target element is 'TextBlock' (Name=''); target property is 'Foreground' (type 'Brush')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.ContentPresenter', AncestorLevel='1''. BindingExpression:Path=(TextElement.Foreground); DataItem=null; target element is 'TextBlock' (Name=''); target property is 'Foreground' (type 'Brush')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.ContentPresenter', AncestorLevel='1''. BindingExpression:Path=(TextElement.Foreground); DataItem=null; target element is 'TextBlock' (Name=''); target property is 'Foreground' (type 'Brush')

Setup

  • 2020 R2 SP1 NoXaml Assemblies (.NET Framework)
  • Office2016Touch Theme
  • Style with the default extracted ControlTemplate (no custom changed required).

 

For your convenience, a reproducible project is attached.

Completed
Last Updated: 19 Feb 2018 15:07 by ADMIN
The fix will be available in the R1 2018 SP2 Release.
Completed
Last Updated: 21 Oct 2016 10:35 by Artem
Completed
Last Updated: 23 Mar 2018 07:00 by ADMIN
Won't Fix
Last Updated: 06 Mar 2024 17:02 by ADMIN

Depending on the chosen theme, the page TextBox will not display all of the digits. This is inconvenient in scenarios where the RadDataPager has many pages.

To work this around, subscribe to the Loaded event of RadDataPager and retrieve the ScrollContentPresenter element with x:Name="PART_ScrollContentPresenter" using the ChildrenOfType extension method and set its Width property to the desired value and HorizontalAlignment property to Center.

private void radDataPager_Loaded(object sender, RoutedEventArgs e)
{
    RadDataPager radDataPager = (RadDataPager)sender;

    ScrollContentPresenter scrollContentPresenter = radDataPager
        .ChildrenOfType<ScrollContentPresenter>().FirstOrDefault(x => x.Name == "PART_ScrollContentPresenter");

    if (scrollContentPresenter != null )
    {
        scrollContentPresenter.Width = 45;
        scrollContentPresenter.HorizontalAlignment = HorizontalAlignment.Center;
    }
}

Unplanned
Last Updated: 21 Sep 2023 11:08 by Martin Ivanov
Changing the DataContext at runtime, will trigger reset of the collection view in the internal view model of RadDataPager. This sets the PageIndex to -1 just the before the context is actually changed, which leads to wrong value in the view model.

To work this around, instead of using data bindings for the panging properties (PageIndex, PageSize, ItemCount), sync them with the view model, manually in code-behind.
Declined
Last Updated: 21 Mar 2014 10:49 by ADMIN
Found with JustDecompile :
 [DefaultValue(-1)]
        public int PageIndex
        {
            get
            {
                return (int)base.GetValue(RadDataPager.PageIndexProperty);
            }
            set
            {
                base.SetValue(RadDataPager.PageIndexProperty, value);
            }
        }

When binding values to PageSize and PageIndex, the default value cause erratic exceptions... 

System.ArgumentOutOfRangeException: PageIndex cannot be negative when PageSize is positive.

I actually never set negative value, it seems to be caused by your default value...

I also get this sometimes :
PageIndex can only be set to -1 when the PageSize is 0

I don't see how 0 could be a valid value in this case, and I never set it to 0, Why would I want to put -1 as PageIndex? 0 would be the right default value IMHO.

How can I make it work?