static void name_Click(object sender, RoutedEventArgs e) { // The event handler in the main application can handle the click event in a custom // fashion (i.e., show the tweets in Witty or launch a URL, etc). That behavior is // not implemented here. try { if (e.OriginalSource is Hyperlink) { Hyperlink h = e.OriginalSource as Hyperlink; if (h.Parent is TweetTextBlock) { TweetTextBlock p = h.Parent as TweetTextBlock; p.RaiseEvent(new RoutedEventArgs(NameClickEvent, h)); return; } } // As a fallback (i.e., if the event is not handled), we launch the hyperlink's // URL in a web browser System.Diagnostics.Process.Start(((Hyperlink)sender).NavigateUri.ToString()); } catch { //TODO: Log specific URL that caused error MessageBox.Show("There was a problem launching the specified URL.", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }
static void hashtag_Click(object sender, RoutedEventArgs e) { try { if (e.OriginalSource is Hyperlink) { Hyperlink h = e.OriginalSource as Hyperlink; if (h.Parent is TweetTextBlock) { TweetTextBlock p = h.Parent as TweetTextBlock; p.RaiseEvent(new RoutedEventArgs(HashtagClickEvent, h)); return; } } // As a fallback (i.e., if the event is not handled), we launch the hyperlink's // URL in a web browser System.Diagnostics.Process.Start(((Hyperlink)sender).NavigateUri.ToString()); } catch { //TODO: Log specific URL that caused error MessageBox.Show("There was a problem launching the specified URL.", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }