This is a migrated thread and some comments may be shown as answers.

Walking the visual tree

1 Answer 67 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Raj
Top achievements
Rank 1
Raj asked on 25 Feb 2010, 02:02 PM
 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?

1 Answer, 1 is accepted

Sort by
0
Raj
Top achievements
Rank 1
answered on 25 Feb 2010, 03:04 PM
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... 
                }); 
        } 

Tags
Calendar
Asked by
Raj
Top achievements
Rank 1
Answers by
Raj
Top achievements
Rank 1
Share this question
or