Here I will post problems I and my colleagues met and solutions we found.

Saturday, August 09, 2008

How to implement LinkControl in WPF

There is no LinkControl in WPF, so if you need to have hyperlink in your form, different approach is needed. I used this:

XAML:

<TextBlock>Go<Hyperlink NavigateUri="http://counttime.alexeyev.org" Click="Hyperlink_Click">http://counttime.alexeyev.org</Hyperlink></TextBlock>

C#:

private void Hyperlink_Click(object sender, RoutedEventArgs e)

{
Hyperlink link = (Hyperlink)sender;
Process.Start(link.NavigateUri.AbsoluteUri);
}

No comments: