I'm using WPF and an Hyperlink control with
<TextBlock Margin="98,190,116,133.418" FontSize="14">
<Hyperlink Name="hyperlink" RequestNavigate="Hyperlink_RequestNavigate">
Click here
</Hyperlink>
</TextBlock>
this is working, but I would like to set the "click here" value by code, but I'm unable to find the correct property.
hyperlink.Value ?
hyperlink.Text ?
Thanks in advance for your help
An alternative answer, which I consider more straightforward than working with the inlines is to put a TextBlock
(with x:Name
) inside the Hyperlink
and then call its Text
property in the code behind:
<TextBlock Margin="98,190,116,133.418" FontSize="14">
<Hyperlink Name="hyperlink" RequestNavigate="Hyperlink_RequestNavigate">
<TextBlock x:Name="hyperlinkText"/>
</Hyperlink>
</TextBlock>
Then in code behind you can set the hyperlink's text by calling hyperlinkText.Text
, like this:
private void Button_Click(object sender, RoutedEventArgs e)
{
this.hyperlinkText.Text = "some custom text";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With