Add image into a tooltip
Asked Answered
H

2

10

I have some TextBlocks with tooltips and I'd like to add an image into the tooltips (that means, I'd like to have tooltips with text and images).

Does anybody knows how could I do that in a simple way?

Thanks a lot!

Heida answered 19/10, 2012 at 18:24 Comment(0)
P
17

This is one way to approach it:

<TextBlock>
    <TextBlock.ToolTip>
        <StackPanel Orientation="Horizontal">
            <Image Source="images/Item 2.gif" />
            <TextBlock>My tooltip text</TextBlock>
        </StackPanel>
     </TextBlock.ToolTip>

    Here is my text.
</TextBlock>
Placement answered 19/10, 2012 at 18:27 Comment(0)
I
1

Instead of

<TextBlock ToolTip="Content"/>

You can do:

<TextBlock>
    <TextBlock.ToolTip>
    <!--insert everything you want here-->
        <TextBlock Text="Content"/>
    </TextBlock.ToolTip>
</TextBlock>
Imray answered 19/10, 2012 at 18:28 Comment(2)
To add additional elements to the tooltip, the children of TextBlock.ToolTip must be wrapped in a container of sorts (etc Grid, StackPanel, etc)Placement
I didnt know that, i always thought the template was using a plain ContentPresenter. I got some reflecting to do i t seems.Imray

© 2022 - 2024 — McMap. All rights reserved.