mattvanleuten
mattvanleuten

Reputation: 25

Hyperlinks in WPF browser not working

I have included a browser control in a WPF app I'm working on and when hyperlinks in the displayed web page are clicked nothing happens. To go to another page I have to right-click on the link and select open. Any ideas why?

Upvotes: 1

Views: 1174

Answers (2)

Marcus
Marcus

Reputation: 116

I don't know if Syed Shoaib Abidi's answer is just different syntax for the same thing, but:

link.RequestNavigate += UrlClicked;

...
private void Url_Clicked(object sender, RequestNavigateEventArgs e)
{
Process.Start(e.Uri.ToString());
}

Upvotes: 1

Syed Shoaib Abidi
Syed Shoaib Abidi

Reputation: 2366

I think you need to handle the RequestNavigate event:

link.RequestNavigate += (sender, e) =>
{
    System.Diagnostics.Process.Start(e.Uri.ToString());
};

Reference: C# Hyperlink in TextBlock: nothing happens when I click on it

Upvotes: 2

Related Questions