How create TextWrapping in a HyperlinkButton using SilverLight

Posted by bcherney on February 26, 2009 under Nerd Herd | 2 Comments to Read

When using the HyperlinkButton in Silverlight you may come across a scenario where you need the content to wrap. Unfortunately the HyperlinkButton control does not allow you to set the TextWrapping =”Wrap”. Here is a quick way I found to allow for this type of functionality.

Original .NET C#

<HyperlinkButton Content=”{Binding Title}” NavigateUri=”{Binding HrefLink}” TextWrapping=”Wrap” Style=”{StaticResource TitleLink}”/>

Modified .NET C#

<HyperlinkButton NavigateUri=”{Binding HrefLink}” Style=”{StaticResource TitleLink}”>
<HyperlinkButton.Content>
<TextBlock TextWrapping=”Wrap” Text=”{Binding Title}”/>
</HyperlinkButton.Content>
</HyperlinkButton>

If you have another way of doing this please let me know. Good luck.


Add A Comment