In XAML, I have the following code:
<Label Width="120" Height="20" Name="label1" SnapsToDevicePixels="True" HorizontalAlignment="Left" VerticalAlignment="Bottom"> <TextBlock VerticalAlignment="Center" HorizontalAlignment="Left"> click <Hyperlink RequestNavigate="Hyperlink_RequestNavigate" NavigateUri="foo">here</Hyperlink> please </TextBlock> </Label>
Now I want to get rid of the entire XAML text block and add this bit programmatically. I have nothing to create a TextBlock by setting the Text property to "click" please and adding a hyperlink to TextBlock.Content . But how to place a hyperlink between 'click' and "please"? And how to set the text of the hyperlink to "here"?
I canβt do much, until all I got is:
label2.Content = new TextBlock() { Text = "click please" }; //(label2.Content as TextBlock).Content does not exist? //and even if it does.. how do I squeeze the hyperlink in between the text?
mtijn source share