wpf 将图像添加到工具提示中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12980236/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 05:50:31  来源:igfitidea点击:

Add image into a tooltip

wpfimagetooltiptextblock

提问by Guilherme Campos

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).

我有一些带有工具提示的 TextBlocks,我想在工具提示中添加一个图像(这意味着,我想有带有文本和图像的工具提示)。

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

有谁知道我怎么能以简单的方式做到这一点?

Thanks a lot!

非常感谢!

回答by RQDQ

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>

回答by MrDosu

Instead of

代替

<TextBlock ToolTip="Content"/>

You can do:

你可以做:

<TextBlock>
    <TextBlock.ToolTip>
    <!--insert everything you want here-->
        <TextBlock Text="Content"/>
    </TextBlock.ToolTip>
</TextBlock>