Skip to main content

Microsoft Silverlight

Answered Question TextBlock and TextWrapping/Margin bug...RSS Feed

(0)

Harlequin
Harlequin

Member

Member

198 points

144 Posts

TextBlock and TextWrapping/Margin bug...

It seems if you give yout TextBlock a margin, and put on TextWrapping, the measuring seems to be wrong.

Repro:

1) Put a TextBlock inside of a Grid
2) Give the TextBlock a Margin, something like 4
3) Put TextWrapping="Wrap" on the TextBlock

If you do this a word like 'Hello' comes out like:
Hell
o

I had to wrap my TextBlocks in another Grid with a margin on the Grid because of this. Anyone else get this issue?

StefanWick
StefanWick

Contributor

Contributor

2864 points

438 Posts

Microsoft

Re: TextBlock and TextWrapping/Margin bug...

Can you include the repro XAML? Does setting UseLayoutRounding="False" help?

Thanks, Stefan Wick

Microsoft Silverlight | http://blogs.msdn.com/swick/

Harlequin
Harlequin

Member

Member

198 points

144 Posts

Re: TextBlock and TextWrapping/Margin bug...

Repro in my message was enough for me to get it. Then I noticed that the fonts we are using for this internal Microsoft thing is Segoe and other fonts in it's family. I'm guessing the measuring of the fonts are not being done correctly or something. Some we are using are segoebkc.ttf and SegoeLight.ttf. Feeling it's the new font rendering engine perhaps.

StefanWick
StefanWick

Contributor

Contributor

2864 points

438 Posts

Microsoft
Answered Question

Re: TextBlock and TextWrapping/Margin bug...

Does setting UseLayoutRounding="False" help?

Microsoft Silverlight | http://blogs.msdn.com/swick/

Harlequin
Harlequin

Member

Member

198 points

144 Posts

Re: TextBlock and TextWrapping/Margin bug...

Oddly enough, yeah that helped. I thought UseLayoutRounding was to help things like Borders not get stuck with half pixels or something, so it makes them do nice crisp ones. Unless I'm reading the property info wrong.

What is this actually doing to the Segoe-based text to help it render fully?

CleverCoder
CleverCoder

Member

Member

203 points

157 Posts

Re: TextBlock and TextWrapping/Margin bug...

 I can confirm that this is an issue for me as well. I have a Grid in Canvas Layout mode that contains a few text blocks. When their width is auto and the grid is set to "UseLayoutRounding" == true, the width of the text blocks don't properly adjust to the proper width and cause unnecessary wrapping. Setting UseLayoutRounding=false on the grid solves the problem.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities