Make a silverlight text block as a hyperlink

I am new to Silverlight. I have a text block that appears inside a datagrid (in the DataGridTemplateColumn.CellTemplate template, to be precise).

I would like to dynamically make some of the text blocks into hyperlinks that open a new window.

Is there a way to do this - for now, all I can think of is to use the hyperlink button and try to style it as a text block.

Any help would be greatly appreciated.

+4
source share
1 answer

HyperlinkButton is a ContentControl, so it can actually use some kind of pre-written TextBlock (or other control) as content (instead of just a string as content).

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

You will need to use the custom HyperlinkButton template if you want to style it to get rid of the default color background ring, etc. You can also set the IsEnabled property for HyperlinkButton to false to prevent the links from behaving to any cells that were not actually links if you are trying to configure them in some dynamic way.

+2
source

Source: https://habr.com/ru/post/1314523/


All Articles