开发者

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开发者_StackOverflow LINE BREAK {0}'} 


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.


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 &#x0a; is just an encoding for hex character A = decimal 10 = \r (carriage return).

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

Note Hex encoding normally requires pairs of digits so &#xd; was the actual error.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜