2
votes

I have multiple TextBlocks in a control. The blocks have a fixed width and the TextWrap property is set to Wrap. The text is provided via binding.

Right now the wrapping occurs when SL detects that it can't fit another character in the line. Which results in something like "The quick bro" \r\n "wn fox jumps".

But I want those blocks to wrap their text only at word boundaries and not at some random position in the middle of a word. The expected outcome should look something like "The quick brown" \r\n "fox jumps".

This is the XAML for one of the TextBlocks:

<TextBlock 
  x:Name="Foo" 
  Foreground="#FFD4E4FF"
  FontSize="14.667"
  FontFamily="Arial"
  Canvas.Left="586.671"
  LineHeight="23.707"
  TextWrapping="Wrap" 
  Text="{Binding Bar}" 
  Canvas.Top="170" 
  Width="120" />

Any ideas?

1
What causes wrapping (what changes the size of TextBlock)? In SL4 and SL5 my TextBlock just stubbornly wraps by words, not letters, when there`s enough width to fit a word.icebat
@icebat The control that hosts the TextBlocks is ridiculously complex. I copied a lot of the stuff from there to a blank solution to find what causes that weird wrapping behavior. But as you said: It keeps wrapping by words. I guess some combination of controls in there really messes up the wrapping process.Sebastian Weber
My guess was that this strange wrapping can be caused by restricted height. If TextBlock with given height and width just can`t fit whole text with word wrapping, then it`s forced to break words.icebat

1 Answers

0
votes

We finally found the problem. For some reason the strings we loaded from the database contained characters that looked like regular blanks in the debugger and in text editors but where not treated as such by Silverlight. The character in question was a non-breaking space