Reputation: 140
I have Email Id in a UWP text-block, how do i make it a "hyperlink" so that when i click on it, it should take me to outlook\email.
Below is the code
public string EmailID
{
get => _emailID;
set
{
_emailID = value;
OnPropertyChanged("EmailID");
}
}
XAML:
<TextBlock DataContext="{StaticResource Email}"
Text="{Binding List.EmailID, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
Do i need to use HyperlinkButton instead of Textblock?
Upvotes: 2
Views: 2001
Reputation: 140
Thank you all, below approach helped me to fix
<HyperlinkButton NavigateUri="{Binding List.EmailLink}"
Style="{StaticResource ResourceKey=HyperlinkStyle}" Content="{Binding List.Email}" />
properties:
public string EmailLink {get { return "mailto:" + _email; }set { }}
public string Email {get => _email;set{_email = value;}}
Upvotes: 0
Reputation: 2581
You can use HyperLinks.
Set the NavigateUri
of the HyperLink
to the mail uri like this:
<TextBlock>
<Hyperlink NavigateUri="mailto:[email protected]"> Email me human</Hyperlink>
</TextBlock>
or probably you can bind it to the backend string provided that the string starts with "mailto:", like this:
TextBlock>
<Hyperlink NavigateUri="{x:Bind myuri}">Email</Hyperlink>
</TextBlock>
and int he back end:
string myuri = "mailto:[email protected]";
Upvotes: 3