Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. HypreLink in WPF User control.

HypreLink in WPF User control.

Scheduled Pinned Locked Moved WPF
csharpwpfquestion
4 Posts 4 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    saku69
    wrote on last edited by
    #1

    Hey everyone, I am doing my first WPF User control. I am trying to get my hyperlink to open a new IE browser when I press a on my "link label". my code sampel; When I press on the HyperLink nothing happen. This is a sampel of my code behid class; namespace WpfShowResultsControl { public partial class GetSearchResultUserControl : UserControl { public GetSearchResultUserControl() { InitializeComponent(); } void HandleRequestNavigate(object sender, RoutedEventArgs e) { string navigateUri = hl.NavigateUri.ToString(); Process.Start(new ProcessStartInfo(navigateUri)); e.Handled = true; } } } I have tried many eksampels on diffrent forums and I cannot get it works. I have also tried like this :( :confused: In my code behind class, I cannot use hl, it looks like it does not exist. What can I do to get hl useable? Could any one please advice me what I am missin in my code. Many thanks in advance! :confused::confused:

    S A 2 Replies Last reply
    0
    • S saku69

      Hey everyone, I am doing my first WPF User control. I am trying to get my hyperlink to open a new IE browser when I press a on my "link label". my code sampel; When I press on the HyperLink nothing happen. This is a sampel of my code behid class; namespace WpfShowResultsControl { public partial class GetSearchResultUserControl : UserControl { public GetSearchResultUserControl() { InitializeComponent(); } void HandleRequestNavigate(object sender, RoutedEventArgs e) { string navigateUri = hl.NavigateUri.ToString(); Process.Start(new ProcessStartInfo(navigateUri)); e.Handled = true; } } } I have tried many eksampels on diffrent forums and I cannot get it works. I have also tried like this :( :confused: In my code behind class, I cannot use hl, it looks like it does not exist. What can I do to get hl useable? Could any one please advice me what I am missin in my code. Many thanks in advance! :confused::confused:

      S Offline
      S Offline
      schiebel t
      wrote on last edited by
      #2

      hi you can try this: make an click event on you textblok. and in you click event call: System.Diagnostics.Process.Start("http://www.google.de");

      1 Reply Last reply
      0
      • S saku69

        Hey everyone, I am doing my first WPF User control. I am trying to get my hyperlink to open a new IE browser when I press a on my "link label". my code sampel; When I press on the HyperLink nothing happen. This is a sampel of my code behid class; namespace WpfShowResultsControl { public partial class GetSearchResultUserControl : UserControl { public GetSearchResultUserControl() { InitializeComponent(); } void HandleRequestNavigate(object sender, RoutedEventArgs e) { string navigateUri = hl.NavigateUri.ToString(); Process.Start(new ProcessStartInfo(navigateUri)); e.Handled = true; } } } I have tried many eksampels on diffrent forums and I cannot get it works. I have also tried like this :( :confused: In my code behind class, I cannot use hl, it looks like it does not exist. What can I do to get hl useable? Could any one please advice me what I am missin in my code. Many thanks in advance! :confused::confused:

        A Offline
        A Offline
        ABitSmart
        wrote on last edited by
        #3

        From [^] "Hyperlink is "navigation service" aware, which means it can work properly as you expect in navigation application(using NavigationWindow, Frame which can provide navigation service). In standalone non-navigation application, you can hook up to its Click event, and implement the navigation logic there." So, in your case you will need to use click handler as suggested ^^

        L 1 Reply Last reply
        0
        • A ABitSmart

          From [^] "Hyperlink is "navigation service" aware, which means it can work properly as you expect in navigation application(using NavigationWindow, Frame which can provide navigation service). In standalone non-navigation application, you can hook up to its Click event, and implement the navigation logic there." So, in your case you will need to use click handler as suggested ^^

          L Offline
          L Offline
          Leung Yat Chun
          wrote on last edited by
          #4

          I hope you found this useful : private void Windows_Loaded(object sender, RoutedEventArgs e) { AddHandler(Hyperlink.ClickEvent, (RoutedEventHandler)Hyperlink_Click); } private void Hyperlink_Click(object sender, RoutedEventArgs e) { if (e.OriginalSource is Hyperlink) { Process.Start((e.OriginalSource as Hyperlink).NavigateUri.AbsoluteUri); e.Handled = true; } }

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups