¿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:
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" .
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.
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.
Another approach that I find useful is to embed 

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 
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.
<Label> <Label.ToolTip> <TextBlock> Lorem ipsum dolor sit amet, <LineBreak /> consectetur adipiscing elit. </TextBlock> </Label.ToolTip> </Label> ....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With