long single line of text does not wrap


If you have a single line of text, with no links in, that is longer than the control the linklabel is a child of the text will not wrap.
From looking at the source this is becuase if a single (with no links) string of text is displayed you just create a single textblock and add this to the wrap panel. Unfortunately this means it does not wrap for long lines of text.
I have done a quick bodge in my code that splits the text into words and adds each as a textblock in the same way you do when there are links in the text but it needs some refactoring to not be a bodge.
For uses like the I have, where I do not know if the text has links in or not until its displayed this is a critical issue.
Thanks for the great control and I hope this fix will help others wondering why it doesnt work


Emil wrote Mar 18, 2009 at 11:08 AM

Hi Brian,

If I understand you correctly you need just to set the TextStyle property and to define TextWrapping = Wrap in it. That will solve your problem.

Basically this would look like that:

<local:LinkLabel TextStyle="{StaticResource LinkLabelDefaultTextStyle}">...

<Style x:Name="LinkLabelDefaultTextStyle" TargetType="TextBlock">
    <Setter Property="TextWrapping" Value="Wrap" />            

Let me know whether this is what you meant.

Hope that helps!

benhenderson wrote Nov 8, 2009 at 5:43 AM

Hi Emil,

This solution worked for me. Thanks for creating and supporting this control. As far as I can tell, it's still the only option for the embedding hyperlinks inside text content.

  • Ben

wrote Jun 29, 2010 at 8:21 PM

atconway wrote Jun 30, 2010 at 1:27 PM

Actually upon further review, the solution from Emil does fix the problem. Just add that static resource to the XAML and reference it as shown in the 'TextStyle' property of the LinkLabel control.

wrote May 1, 2012 at 9:09 PM

wrote Feb 13, 2013 at 7:35 PM