I have a customized button in my interface, defined with the following style:
<Style x:Key="KinectCustomButton" TargetType="k:KinectCircleButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="k:KinectCircleButton">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="60*"/>
<RowDefinition Height="40*"/>
</Grid.RowDefinitions>
<k:KinectCircleButton Grid.Row="0" VerticalAlignment="Bottom" Foreground="{TemplateBinding Foreground}" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
<ContentPresenter x:Name="content"/>
</k:KinectCircleButton>
<ScrollViewer Grid.Row="1">
<TextBlock TextAlignment="Center" VerticalAlignment="Top" TextWrapping="Wrap" Text="{TemplateBinding Label}" Foreground="{TemplateBinding Foreground}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontWeight="{TemplateBinding FontWeight}"/>
</ScrollViewer>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
I instantiated six of these buttons in my window. Now I need to access the ScrollViewer element for each one of these buttons. I tried this method: How can I find WPF controls by name or type? but it's not working. I also tried to access the Template property of my customized KinectCustomButton, but if I try to find the ScrollViewer instance I get the one coming from the template instead of the one in the button instance (so the text of the TextBlock inside of it is empty). Is there any method to obtain what I want?