In the code behind I cannot seem to access the Image (or any child) control of a Tooltip of an Image.
Setup: I have a UserControl with an image that on hover displays a tooltip with a larger version of the same source. The control is added to my View using:
<local:GetFrame x:Name="getframe" />
The image is then defined within the usercontrol as follows:
<StackPanel Orientation="Horizontal" x:Name="stkImage">
<TextBlock Text="Latest Image" Margin="0,0,5,0"/>
<Image Name="lastImageThumbnail" Source="/Content/blank.jpg" Height="30" Width="30" ToolTipService.ShowOnDisabled="True">
<Image.ToolTip>
<ToolTip Placement="Bottom">
<ToolTip.Template>
<ControlTemplate>
<StackPanel>
<Path Margin="5,0,0,0" Fill="DarkGray" Data="M 0 16 L 16 0 L 32 16 Z"/>
<Image Name="lastImage" Height="400" Width="400" Source="/Content/blank.jpg"/>
</StackPanel>
</ControlTemplate>
</ToolTip.Template>
</ToolTip>
</Image.ToolTip>
</Image>
At compile time both Image controls point to a resource of a 'default' image. At runtime after I trigger some action I want to update the Source for both images to a new image, but I cannot seem to access the child Image control. On this action lastImageThumbnail changes to my runtime BitmapImage.
if (File.Exists(fullpath))
{
var image = new BitmapImage(new Uri(fullpath));
getframe.lastImageThumbnail.Source = image;
getframe.lastImage.Source = image;
}
getframe.lastImage.Source has error S1061 'GetFrame' does not contain a definition for 'lastImage.... by giving the control a unique name I believed in WPF I should be able to access it but this does not appear to be the case.