2014-02-19 17 views
0

這個mailto鏈接並不在此示例中的工作:如何讓NavigateUri在WPF窗口中工作?

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
    <TextBlock>Please email 
     <Hyperlink NavigateUri="mailto:[email protected]">[email protected]</Hyperlink> 
    </TextBlock> 
</Window> 

它的工作原理,如果我改變窗口給用戶控件。

任何人都可以幫忙嗎?

+0

你可能想看看這個問題: http://stackoverflow.com/questions/1963532/how-to-get-a-simple-hyperlink-to-work-in-xaml –

+0

看看這個吧:http://stackoverflow.com/questions/10238694/example-using-hyperlink-in- wpf – Sankarann

回答

6

在XAML:您需要添加RequestNavigate

    <TextBlock > 
         Please email <Hyperlink NavigateUri="mailto:[email protected]" RequestNavigate="Hyperlink_RequestNavigate">[email protected]</Hyperlink> 
        </TextBlock> 

在後面的代碼:

private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e) 
    { 
     Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri)); 
     e.Handled = true; 
    } 
+1

工作過。感謝您的幫助。 –

+0

我收到異常「找不到程序」。 – matsolof