如何在XAML中的文本中的电子邮件链接? [英] How to have an email link inside a text in Xaml?
问题描述
我在一款Windows Phone 8应用一些大的文本,我希望这是内部电子邮件中的链接,像一个mailto功能。
下面的代码的一部分:
I have some large texts in a Windows phone 8 app and I want there to be e-mail links inside, something like a mailto feature. Here's a part of the code:
<phone:PivotItem Header="μέλη ΔΕΠ">
<ScrollViewer>
<StackPanel>
<TextBlock TextWrapping="Wrap">
<Run Text="John Doe"/>
<LineBreak/>
<Run Text="503 (Building DS 126)"/>
<LineBreak/>
<Run Text="tel.: +30 210-1234567"/>
<LineBreak/>
<Run Text="e-mail: johndoe@uni.gr"/>
</TextBlock>
</StackPanel>
</ScrollViewer>
</phone:PivotItem>
我就喜欢的电子邮件:johndoe@uni.gr要点击并打开在手机上的邮件应用程序。
中有更大的文字这样相当多的情况下,在我的电子邮件的代码,这就是为什么我使用< TextBlock的><运行文本=/>< ;断行/方式> ...
格式
现在我知道我不能使用<运行文本=/>
所以任何建议。
Now I know I can't use a hyperlink button inside the <Run Text=".."/>
so any suggestions?
推荐答案
HyperlinkButton是好的,如果你想在你的UI中的超链接,但如果你想镶嵌在文本来看,你应该用一个超链接的的RichTextBox 与超链接
HyperlinkButton is good if you want a hyperlink in your UI, but if you want a hyperlink embedded in a run of text you should use RichTextBox with a Hyperlink:
<RichTextBox TextWrapping="Wrap">
<Paragraph>
<Run Text="John Doe" />
<LineBreak />
<Run Text="503 (Building DS 126)" />
<LineBreak />
<Run Text="tel.: +30 210-1234567" />
<LineBreak />
<Hyperlink Click="Hyperlink_OnClick">e-mail: johndoe@uni.gr</Hyperlink>
</Paragraph>
</RichTextBox>
然后用从朱利安的回答的处理程序:
And then use the handler from Julien's answer:
private void Hyperlink_OnClick(object sender, RoutedEventArgs e) {
EmailComposeTask emailComposeTask = new EmailComposeTask();
emailComposeTask.Subject = "message subject";
emailComposeTask.Body = "message body";
emailComposeTask.To = "johndoe@uni.gr";
emailComposeTask.Show();
}
祝你好运!
Good luck!
这篇关于如何在XAML中的文本中的电子邮件链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!