Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a breakline in tooltip

Tags:

wpf

tooltip

xaml

¿How can I add a breakline to a text inside a tooltip in XAML?

I try with this:

        <Label Name="label4" UseLayoutRounding="False" Focusable="False" AllowDrop="False" Foreground="Black" Margin="6,44,132.027,76" ToolTipService.ShowDuration="12000">                 <Label.ToolTip>                     <ToolTip>                     <TextBlock>Lorem ipsum dolor sit amet, consectetur adipiscing elit. </TextBlock>                     <TextBlock>Suspendisse eget urna eget elit ullamcorper tincidunt. Sed nec arcu sed ante sodales </TextBlock>                     <TextBlock>Pellentesque elit libero, semper ac tincidunt vitae, euismod at ligula.</TextBlock>                     </ToolTip>                 </Label.ToolTip>             <Label.Content>                 <TextBlock TextAlignment="Right" TextWrapping="Wrap" Height="19" Width="108" >Lorem Ipsum</TextBlock>             </Label.Content>         </Label> 

But doesn't works:

like image 748
Galled Avatar asked Nov 17 '11 16:11

Galled


People also ask

How do I add content to tooltip?

Basic Tooltip HTML: Use a container element (like <div>) and add the "tooltip" class to it. When the user mouse over this <div>, it will show the tooltip text. The tooltip text is placed inside an inline element (like <span>) with class="tooltiptext" .

How do you add a breakline in CSS?

A line-break can be added in HTML, using only CSS, by employing the pseudo-class ::after or ::before . In the stylesheet, we use these pseudo-classes, with the HTML class or id, before or after the place where we want to insert a line-break.

How do you create a breakline in HTML?

To do a line break in HTML, use the <br> tag. Simply place the tag wherever you want to force a line break. Since an HTML line break is an empty element, there's no closing tag.


2 Answers

Another approach that I find useful is to embed &#x0a; in the tooltip. The Tooltip will then have a Linebreak at this point. For example

ToolTip="Host name or IP address of the server. Click the &#x0a;Find Server button to help obtain the correct entry." 

This allows the xaml code to be more concise, but perhaps less readable. More details at Newline in string attribute.

like image 97
ausadmin Avatar answered Oct 15 '22 05:10

ausadmin


<Label>   <Label.ToolTip>       <TextBlock>           Lorem ipsum dolor sit amet,           <LineBreak />            consectetur adipiscing elit.        </TextBlock>    </Label.ToolTip>  </Label>   .... 
like image 31
HCL Avatar answered Oct 15 '22 06:10

HCL