views:

122

answers:

1

I'm pretty new to silverlight. I have a text block that is displayed inside a datagrid (inside a DataGridTemplateColumn.CellTemplate template to be precise).

I'd like to dynamically make some of the textblocks into hyperlinks that open a new window.

Is there a way to do this - so far all I can come up with is using a hyperlink button and trying to style it to look like a text block.

Any help would be very much appreciated.

+1  A: 

HyperlinkButton is a ContentControl so it can actually take some kind of pre-styled TextBlock (or other control) as it's content (instead of just using a simple string as Content).

<HyperlinkButton NavigateUri="http://myurl.com"&gt;
    <TextBlock Text="My Link Text" Foreground="Black" />
</HyperlinkButton>

You would have to use a custom HyperlinkButton template if you wanted to style it to get rid of the default teal colored focus ring, etc. You could also set the IsEnabled property of the HyperlinkButton to false to prevent link behavior on any cells that weren't actually links if you are trying to set them up in some dynamic way.

Dan Auclair
thanks for that!
bplus