tags:

views:

190

answers:

1

I have a wpf tab control which I added a scrollviewer to. This is all wrapped into a style which is situated in a resource dictionary.

Now, on the window's xaml side, all I do is set .

I would like to access the control viewer element, as defined in the style as follows:

<Style x:Key="MyTabStyle" TargetType="{x:Type TabControl}">
 <Setter Property="Template">
  <Setter.Value>
   <ControlTemplate TargetType="{x:Type TabControl}">
                 <ScrollViewer />
                        .......

How do I access the scrollviewer which is so deeply nested in the heirarchy?

A: 

Give it a name (theScrollViewer for instance), and use the FindName method to access it :

ScrollViewer scrollViewer = theTabControl.Template.FindName("theScrollViewer") as ScrollViewer;
Thomas Levesque