|
-
Mar 11th, 2010, 11:01 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Why does Mouse Down not function?
Hello,
I am new to WPF, so bare with me here. I an attempting to create a hyperlink that launches a webpage. Here is my code.
Code:
<TextBlock Margin="352.5,0,356,232.54" VerticalAlignment="Bottom" TextWrapping="Wrap" MouseLeftButtonDown="Test_Click">
<Hyperlink>Click Here</Hyperlink>
</TextBlock>
And here is the code behind.
Code:
private void Test_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Process.Start("http://www.msn.com");
}
It doesn't do anything when I click down on the mouse... Am I missing something here?
What is the best method for doing hyperlinks? I have created a button template for a hyperlink and can get it to work this way, but I really didn't want a template for each hyperlink I want...
Any direction or help is greatly appreciated!
-
Mar 13th, 2010, 07:52 PM
#2
Lively Member
Re: Why does Mouse Down not function?
Hey there csleech,
Here's some XAML code for using hyperlink control directly:
Code:
<Hyperlink NavigateUri="http://www.msn.com">
Click Here
</Hyperlink>
Hope this helps... Shweet
-
Mar 14th, 2010, 12:07 PM
#3
Thread Starter
Addicted Member
Re: Why does Mouse Down not function?
Hey spike,
The problem with that code is that it doesn't automatically start IE (or whatever the default browser is) and load the webpage. This was the original need for a mouse event, but those aren't working for some reason... I've worked around this by just creating a button template.
-
Mar 16th, 2010, 05:21 AM
#4
Re: Why does Mouse Down not function?
Hi.
Try using the PreviewMouseLeftButtonDown instead.
I have found that MouseDown, MouseLeftButtonDown etc. doesn't always work.
I think it's because a previous handler has set the e.Handled=true, which stops the event from bubbling further up.
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
-
Mar 16th, 2010, 06:42 AM
#5
Thread Starter
Addicted Member
Re: Why does Mouse Down not function?
Pax.... THANKS!!!! That worked great! Not sure why you have to use the Preview portion but I'll take it! That is much simplier than having to create a button template for everything.
-
Mar 16th, 2010, 07:35 AM
#6
Re: [RESOLVED] Why does Mouse Down not function?
You're welcome
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|