链接到在WPF应用程序的默认电子邮件处理程序中打开新邮件 [英] Link to Open New Email Message in Default E-mail Handler in WPF Application
本文介绍了链接到在WPF应用程序的默认电子邮件处理程序中打开新邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的目标是基本的:有一个标签/ texblock什么具备的,你是程式化的,看起来像一个链接一个WPF形式。点击后,控制应该打开用户的默认电子邮件应用一个新的电子邮件撰写窗口。实际上打开新邮件窗口中的代码似乎微不足道:
的Process.Start(电子邮件地址:example@stackoverflow.com ?主题= SubjectExample&安培;机身= BodyExample);
不过我有带两件麻烦:
- 绑定新邮件打开动作标签click事件。
- 风格化的标签,以便它看起来就像一个默认的WPF超链接。
解决方案
如果你想要的风格要像一个超链接,为什么不干脆用一个直接?
<&的TextBlock GT;
<超链接NavigateUri =电子邮件地址:example@stackoverflow.com主题= SubjectExample&放大器;放大器;车身= BodyExampleRequestNavigate =OnNavigate>
点击此处
< /超链接>
< / TextBlock的>
再补充:
私人无效OnNavigate(对象发件人,RequestNavigateEventArgs E)
{
的Process.Start(e.Uri.AbsoluteUri);
e.Handled = TRUE;
}
My goal is basic: Have a label/texblock what-have-you on a WPF form that is stylized to look like a link. When clicked, the control should open a new e-mail composition window in the user's default e-mail app. The code to actually open the new e-mail window seems trivial:
Process.Start("mailto:example@stackoverflow.com?subject=SubjectExample&body=BodyExample ");
However I'm having trouble with two pieces:
- Binding the "new message open" action to a label click event.
- Stylizing the label so that it looks exactly like a default WPF hyperlink.
解决方案
If you want the style to be like a hyperlink, why not just use one directly?
<TextBlock>
<Hyperlink NavigateUri="mailto:example@stackoverflow.com?subject=SubjectExample&body=BodyExample" RequestNavigate="OnNavigate">
Click here
</Hyperlink>
</TextBlock>
Then add:
private void OnNavigate(object sender, RequestNavigateEventArgs e)
{
Process.Start(e.Uri.AbsoluteUri);
e.Handled = true;
}
这篇关于链接到在WPF应用程序的默认电子邮件处理程序中打开新邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文