Saturday, 3 March 2012

Firing up the default Browser

This simple snippet shows how to display a URL in a WPF window and fire up the default browser when the link is clicked.
Starting with a TextBlock in the XAML:
         <Hyperlink Click="Hyperlink_Click"
                    NavigateUri="">Link to original WPF Waltz blog entry</Hyperlink>
And a simple event handler in the code-behind:
      private void Hyperlink_Click(object sender, RoutedEventArgs e)
         Process.Start((sender as Hyperlink).NavigateUri.ToString());

No comments: