Walking the visual tree

2 posts, 0 answers
  1. Raj
    Raj avatar
    34 posts
    Member since:
    Aug 2009

    Posted 25 Feb 2010 Link to this post

     I would like the find the proper scrollviewer in order to offset the start time for the week and day view. In other words I would like to have all hours 12 am - 12 pm available but adjust the scrollviewer to show business hours by default. I'm using the VisualTreeHelper to recursively walk the scheduler tree. However, I notice that the traversal ends with the element SchedulerPresenter. When I look at the same tree in Silverlight Spy there are many other controls under SchedulerPresenter. Why can't I get to them?
  2. Raj
    Raj avatar
    34 posts
    Member since:
    Aug 2009

    Posted 25 Feb 2010 Link to this post

    Ok - found a solution to this. It seems that the control needs to properly initialize before you can get the full visual tree. Using the following code works...

            void scheduler_ActiveViewDefinitionChanged(object sender, EventArgs e) 
            { 
                 
                scheduler.Dispatcher.BeginInvoke(() => 
                    { 
                        SchedulerPresenter sp = scheduler.FindChildByType<SchedulerPresenter>(); 
     
                        // Use VisualTreeHelper to get nested controls here... 
                    }); 
            } 

  3. DevCraft banner
Back to Top