abhi294074
abhi294074

Reputation: 257

Multiple line tool tip in wpf using c#

I want to use multiple line tool tip in wpf but thie is look like

line 1 
    line2

but i want to display this miltiple line tool tip in the given format

line 1
line 2

Upvotes: 4

Views: 5856

Answers (3)

PiotrWolkowski
PiotrWolkowski

Reputation: 8792

That worked for me and I don't see anything similar in the answers:

<[ParentControl].ToolTip>
    <TextBlock>
        Some text here.
        <LineBreak/>    
        And more text in a new line.
    </TextBlock>
</[ParentControl].ToolTip>

Upvotes: 3

dk123
dk123

Reputation: 19710

I personally prefer to embed &#x0a;(new line) into the strings I'll be using as tooltips.

ex. Tooltip="line 1 &#x0a;line 2"

I can then load the strings from resource files and conveniently apply them if I wish without having to go through any additional formatting.

Upvotes: 11

RQDQ
RQDQ

Reputation: 15589

Here is a way to do it with a Label as an example:

<Label>
    <Label.ToolTip>
        <StackPanel>
             <TextBlock>Line 1</TextBlock>
             <TextBlock>Line 2</TextBlock>
        </StackPanel>
    </Label.ToolTip>
</Label>

Upvotes: 6

Related Questions