Set Scroll Bar Position on Selected Page Change Event

3 posts, 0 answers
  1. Khizar Khan
    Khizar Khan avatar
    41 posts
    Member since:
    Jan 2010

    Posted 22 Jul 2011 Link to this post

    Hi ,

    I am trying to do something very simple but seems that this does not work .

    Basically I have a few different RadPageViewPages in a  RadPageView control
    each page has about 9 buttons

    what I want to be able to do is when user clicks on a particular page this should auto scroll to make the contents of the page visible when expanded .i.e ideally scroll to a point where the contents become visible

    currently what seem to happen is when you click on the page to expand it depending on the position of the page the contents are not always visible the user has to manually drag the scrollbar to see its content which is obviously hiding down at the bottom .

    I tried adding the following code to the project but it does not seem to work

    void radPageView1_SelectedPageChanged(object sender, EventArgs e)
                RadPageView apageview = (RadPageView)sender;
                RadPageViewPage apage = (RadPageViewPage)apageview.SelectedPage;

    I have added Screen-prints of what it does and what is expected

  2. Jack
    Jack avatar
    2333 posts

    Posted 28 Jul 2011 Link to this post

    Hello Khizar,

    I apologize for the late reply. I was trying to find an acceptable solution for your question, because this seems to be a missing feature and I added it in our issue tracking system as a feature request. We will consider implementing it in a future version.

    My efforts, in fact, leaded to a solution, that I think covers your requirements. You can implement the desired behavior by overriding RadPageView class and doing some reflection. Please consider the following example:
    public class CustomPageView : RadPageView
        public override string ThemeClassName
            get { return typeof(RadPageView).FullName; }
            set {}
        protected override RadPageViewElement CreateUI()
            return new CustomExplorerBarElement();
    public class CustomExplorerBarElement : RadPageViewExplorerBarElement
        protected override Type ThemeEffectiveType
                return typeof(RadPageViewExplorerBarElement);
        FieldInfo fi;
        MethodInfo mi;
        public CustomExplorerBarElement()
            fi = typeof(RadPageViewExplorerBarElement).GetField("initialLayoutOffset", BindingFlags.Instance | BindingFlags.NonPublic);
            mi = typeof(RadPageViewExplorerBarElement).GetMethod("CorrectLayoutOffset", BindingFlags.Instance | BindingFlags.NonPublic);
        public void ScrollTo(RadPageViewExplorerBarItem item)
            RectangleF clientRect = this.GetClientRectangle(this.Size);
            Padding ncMargin = this.GetNCMetrics();
            clientRect.Y += ncMargin.Top;
            clientRect.X += ncMargin.Left;
            clientRect.Width -= ncMargin.Horizontal;
            clientRect.Height -= ncMargin.Vertical;
            RectangleF itemRectangle = item.BoundingRectangle;
            itemRectangle.Height += item.Page.Height;
            RectangleF intersectionRect = RectangleF.Intersect(clientRect, itemRectangle);
            fi.SetValue(this, (int)fi.GetValue(this) + (int)(clientRect.Top - itemRectangle.Top));
            int initialLayoutOffset = (int)mi.Invoke(this,new object[] {});
            fi.SetValue(this, initialLayoutOffset);           
            this.Scrollbar.Value = -initialLayoutOffset;
        protected override void OnExpandedChanged(RadPageViewExpandedChangedEventArgs e)
            if (e.Expanded)

    I hope this solution fits in your case. If you have further questions, do not hesitate to ask.

    All the best,
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. Duncan Clarke
    Duncan Clarke avatar
    6 posts
    Member since:
    May 2009

    Posted 29 Aug 2011 Link to this post

Back to Top