Get Controls from a DataTemplate inside a ListBox (or Panorama)
I have a Panorama Control and inside it is a DataTemplate and insid开发者_开发百科e the DataTemplate is an Image control. I want to get the Image control of the selected item to change it to something else. The xaml code is like this:
<controls:Panorama x:Name="FeedsPanorama" FontSize="20">
<controls:Panorama.ItemTemplate>
<DataTemplate x:Name="ItemDataTemplate">
<Grid d:DesignWidth="460" d:DesignHeight="700" Width="Auto" Height="Auto">
<Image HorizontalAlignment="Left" Height="118" Margin="2,8,0,0" VerticalAlignment="Top" Width="167" x:Name="ImageThumbnail" Source="{Binding SummaryImageLink}" />
</Grid>
</DataTemplate>
</controls:Panorama.ItemTemplate>
</controls:Panorama>
For example, every items will have their own images, but when it is selected, I will change the image to something else and then change back to it own image.
You need to get the actual container using the ItemContainerGenerator of your control:
FeedsPanorama.ItemContainerGenerator.ContainerFromItem(currentDataObject);
精彩评论