开发者

How do I format/style a Tooltip in Silverlight?

开发者 https://www.devze.com 2023-03-18 10:35 出处:网络
Basically I have an image in my application that I want to add hover text (or tool tip) too.This is easy to do using the ToolTipService.ToolTip attribute on the Image tag.The problem I have is that I

Basically I have an image in my application that I want to add hover text (or tool tip) too. This is easy to do using the ToolTipService.ToolTip attribute on the Image tag. The problem I have is that I require some words in the text to have a font-weig开发者_如何转开发ht of bold.

i.e. This is a test tooltip.

My image tag looks something like this:

<Image Name="HelpIcon" Height="16" Width="16" Source="component/Assets/help.png" Stretch="Uniform" ToolTipService.ToolTip="This is a test tooltip.">

So given this example, how do I make the word test appear bold in the tooltip?


For the tooltip to have rich content you need to define the ToolTip contents as FrameworkElements rather than text.

<Image Source="component/Assets/help.png">
    <ToolTipService.ToolTip>
        <TextBlock>
            This is a <Bold>test</Bold> tooltip.
        </TextBlock>
    </ToolTipService.ToolTip>
</Image>
0

精彩评论

暂无评论...
验证码 换一张
取 消