Valentin Kuzub
Valentin Kuzub

Reputation: 12093

Silverlight binding - how to make StringFormat option multiline in XAML

I am using a pretty long StringFormat for my bound tooltip and am currenly trying to make it multiline in XAML.

While I was able to make literal ToolTip multiline using 
 for line breaks I am unable to get it to work with StringFormat.

I am trying to get following code to give me a tooltip with line break:

ToolTipService.Tooltip= {Binding Property,StringFormat='FORMAT WITH LINE BREAK {0}'} 

Upvotes: 0

Views: 1541

Answers (2)

iCollect.it Ltd
iCollect.it Ltd

Reputation: 93601

In string format output, have you tried using \r instead to insert carriage returns?

The only reason these encodings exist is to allow special character values to be placed in XML/Xaml.

The 
 is just an encoding for hex character A = decimal 10 = \r (carriage return).

Another one of interest is 
 which is character D = decimal 13 = \n (newline).

Note Hex encoding normally requires pairs of digits so 
 was the actual error.

Upvotes: 3

Valentin Kuzub
Valentin Kuzub

Reputation: 12093

Actually I got correct answer here:

official silverlight forums link

We can use 
 for line break.

or :

<TextBox Text="{Binding Path=a, 
         StringFormat='First Line \{0\} &#x0a; Second Line'}" />

Difference is pretty big.. This one works.

Upvotes: 3

Related Questions