tags:

views:

270

answers:

1

I'm creating a WPF application in c# and I have an image control with an image. I want it to show an tooltip with image and text when the mouse if hovering over it. So how do I make a tooptip with an image when the mouse is hovering over it. Thanks in advance to any help.

+1  A: 

Try something like this.

<!-- This is the image that has the tooltip -->
<Image Source="...">
    <Image.ToolTip>
        <!-- A tooltip can contain any element.  Here we put a text
             block and another image. -->
        <StackPanel>
            <TextBlock>This is the tooltip text</TextBlock>
            <!-- This image appears inside the tooltip -->
            <Image Source="..." />
        </StackPanel>
    </Image.ToolTip>
</Image>
Drew Noakes
uhh where exactly would that go?
Jake
I know it goes in the xaml, but is there a specific place?
Jake
I edited the answer to include some comments that indicate placement a little better for you. Does that help?
Drew Noakes
Wow that helps a lot. Thanks Drew. One more thing, How can I position where the tooltip appears and how can I position the text to where ever I want it to appear. Thanks a lot for your help.
Jake
The ToolTip has a 'Placement' property you can use for positioning. As for the text layout, it depends on how you want it to look. If you're new to WPF layout, it's worth playing around with a tool like Kaxaml, and experimenting with the built in layout panels: StackPanel, DockPanel, Grid, WrapPanel, Canvas and UniformGrid. That list is roughly in descending order of usefulness, IMHO.
Drew Noakes