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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. WPF
  4. WPF hyperlink Click event

WPF hyperlink Click event

Scheduled Pinned Locked Moved WPF
wpfcsharpwcfhelpquestion
2 Posts 2 Posters 1 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
    Suj_78
    wrote on last edited by
    #1

    Hi Guys, I have created two xaml files , 1. Page1.xaml and 2. Page2.xaml Page1.xaml has a Hyperlink with click event associated with a method as below: This is a hyperlink to page 2 In page1.xaml.cs, i have created the method hyperlink_Clicked as below: private void hyperlink_Clicked(object sender,System.EventArgs erg) { System.Uri myUri = new Uri("Page2.xaml",System.UriKind.Relative ); myLink.NavigateUri = myUri; } However, when i click on hyperlink for the first time, it does not navigate to page2, but if i click second time it goes to page2. Am i missing anything? late Binding or early binding? Any help , appreciated. Thanks happy coding!

    S 1 Reply Last reply
    0
    • S Suj_78

      Hi Guys, I have created two xaml files , 1. Page1.xaml and 2. Page2.xaml Page1.xaml has a Hyperlink with click event associated with a method as below: This is a hyperlink to page 2 In page1.xaml.cs, i have created the method hyperlink_Clicked as below: private void hyperlink_Clicked(object sender,System.EventArgs erg) { System.Uri myUri = new Uri("Page2.xaml",System.UriKind.Relative ); myLink.NavigateUri = myUri; } However, when i click on hyperlink for the first time, it does not navigate to page2, but if i click second time it goes to page2. Am i missing anything? late Binding or early binding? Any help , appreciated. Thanks happy coding!

      S Offline
      S Offline
      Super Lloyd
      wrote on last edited by
      #2

      Without having tryed to reproduce your issue I suspect that the link would only work if it is in a focused control and that it is not the case when you first click. Setting the focus reliably can only be done in the Loaded event, as it is well undocumented! ;), I suggest you write something as follow: MyControl() { Loaded += (sender, e) => { Focus(); }; }

      A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station.... _________________________________________________________ My programs never have bugs, they just develop random features.

      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