Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3791036
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:24:28+00:00 2026-05-19T12:24:28+00:00

I have a pivot where each pivotItem contains a scrollviewer. What I want to

  • 0

I have a pivot where each pivotItem contains a scrollviewer.
What I want to do is to set the scrollviewer’s offset to a specific number each time I scroll to a new pivot item. I cannot create a databinding because the offset value is not exposed.

There is a ScrollToVerticalOffset() that i can call, but I need first to find which scrollviewer is currently active and get that object, which means the scrollviewer inside the currently selected pivot item.

I tried to get the scrollviewer by traversing the visual tree based on its name but I always get the 1st scrollviewer.

How could I do that?

thanx

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T12:24:28+00:00Added an answer on May 19, 2026 at 12:24 pm

    You could traverse the visual tree by type instead of by name and start at the selected PivotItem, which should mean that the first ScrollViewer that you find will be the one you want.

            /// <summary>
            /// Gets the visual children of type T.
            /// </summary>
            /// <typeparam name="T"></typeparam>
            /// <param name="target"></param>
            /// <returns></returns>
            public static IEnumerable<T> GetVisualChildren<T>(this DependencyObject target)
                where T : DependencyObject
            {
                return GetVisualChildren(target).Where(child => child is T).Cast<T>();
            }
    
    
            /// <summary>
            /// Get the visual tree children of an element.
            /// </summary>
            /// <param name="element">The element.</param>
            /// <returns>The visual tree children of an element.</returns>
            /// <exception cref="T:System.ArgumentNullException">
            /// <paramref name="element"/> is null.
            /// </exception>
            public static IEnumerable<DependencyObject> GetVisualChildren(this DependencyObject element)
            {
                if (element == null)
                {
                    throw new ArgumentNullException("element");
                }
    
                return GetVisualChildrenAndSelfIterator(element).Skip(1);
            }
    
            /// <summary>
            /// Get the visual tree children of an element and the element itself.
            /// </summary>
            /// <param name="element">The element.</param>
            /// <returns>
            /// The visual tree children of an element and the element itself.
            /// </returns>
            private static IEnumerable<DependencyObject> GetVisualChildrenAndSelfIterator(this DependencyObject element)
            {
                Debug.Assert(element != null, "element should not be null!");
    
                yield return element;
    
                int count = VisualTreeHelper.GetChildrenCount(element);
                for (int i = 0; i < count; i++)
                {
                    yield return VisualTreeHelper.GetChild(element, i);
                }
            }

    So you’d end up with something like this:

    var scroller = ((PivotItem)pivot.SelectedItem).GetVisualChildren().FirstOrDefault();
    scroller.ScrollToVerticalOffset(offset);
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of Image URLS .I want to dynamically add Pivot item
I've got a pivot view, with 6 pivotitems. Each pivotitem contains a list of
I want to have panorama control (or pivot ) that each PanoramaItem will be
I have query to show the table like this: but I want to PIVOT
I have data like the following: I want to pivot the data to look
I have made a calendar control based on the pivot control. Every pivot item
basically I have a pivot control in my WP7 app that contains 3 views.
I have a question about how to pivot/total (for want of a better word)
Problem: I have about 50,000 rows in Excel. Each row contains a the word
I have a spreadsheet with a dataset of a number of transactions, each of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.