0

I have a string I get from the app resources called SupportEmail "Send an email to {0} to get access". I want to add an email hyperlink to the placeholder.

I can do it for a string using the following property that I bind to

public string SupportEmail {
get {
 return String.Format(AppResources.SupportEmail, DesiredEmail);
    }
}

And xaml code:

<TextBlock Text="{Binding SupportEmail }" />

Current implementation: Send an email to john@doe.com to get access

Desired implementation: Send an email to john@doe.com to get access

How can I achieve this such that the email is a hyperlink?

  • usually hyperlink should be displayed in richtextblock control https://msdn.microsoft.com/en-us/library/system.windows.controls.richtextbox.blocks(v=vs.95).aspx – Swift Sharp Jan 05 '17 at 11:26

1 Answers1

0

This might do the trick for you

<TextBlock>Send an email to 
    <Hyperlink NavigateUri="john@doe.com" 
               RequestNavigate="OnNavigate">john@doe.com
    </Hyperlink> 
    to get access
</TextBlock>

and in code behind

private void OnNavigate(object sender, RequestNavigateEventArgs e)
{
    Process.Start(e.Uri.AbsoluteUri);
    e.Handled = true;
}
Mohit S
  • 13,723
  • 6
  • 34
  • 69
  • I need to use the appresource string because I support multiple languages @mohit-shrivastava – macgriffiths Jan 05 '17 at 07:47
  • See if [programmatically make textblock with hyperlink in between text](http://stackoverflow.com/a/7890287/3796048) might help you – Mohit S Jan 05 '17 at 07:54