I have an image displayed in a DataTemplate. I want to change the DataTemplate style that surrounds my image when the image is clicked.
It was embedded directly on the stack, as shown below, so I could easily get the parent stack pane by doing the following.
StackPanel sp = img.Parent as StackPanel;
<StackPanel Name="uxSessionImageItem" Style="{DynamicResource RotatorItemTemplateUnselectedStyle}" Loaded="uxSessionImageItem_Loaded" >
<TextBlock Name="uxLabel" Width="150" Text="{Binding SessionImageID}" Foreground="White" VerticalAlignment="Center"/>
<Image MouseDown="ImagePanel_MouseDown" Name="uxImage" Style="{DynamicResource ItemTemplateImageStyle}" Source="{Binding ThumbPath}"/>
</StackPanel>
I had to add another glass panel and the border between the image and the stack panel that I need to find. What syntax do I need to find, not the border, which is now my parent, or the stack panel, which is the parent border, but the stack panel above this?
<StackPanel Name="uxSessionImageItem" Style="{DynamicResource RotatorItemTemplateUnselectedStyle}" Loaded="uxSessionImageItem_Loaded" >
<TextBlock Name="uxLabel" Width="150" Text="{Binding SessionImageID}" VerticalAlignment="Center" Style="{DynamicResource ItemTemplateImageNumberStyle}"/>
<StackPanel Name="uxSessionImageWrapper" Style="{DynamicResource RotatorItemImageWrapperStyle}" >
<Border Name="uxImageBorder" Style="{DynamicResource ItemTemplateImageBorderStyle}">
<Image MouseDown="ImagePanel_MouseDown" Name="uxImage" Style="{DynamicResource ItemTemplateImageStyle}" Source="{Binding ThumbPath}"/>
</Border>
</StackPanel>
</StackPanel>
source
share