Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8858085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:44:51+00:00 2026-06-14T14:44:51+00:00

I found a lot of example explaining bubbling but none about Tunneling this is

  • 0

I found a lot of example explaining bubbling but none about Tunneling this is about Tunneling eg parent to child. I think my main problem is that i don’t understand how to register the routed event in the child (WindowControl to UserControl).
I got:

public partial class MyParent : UserControl
{
  public static readonly RoutedEvent RoutedMouseUpEvent = EventManager.RegisterRoutedEvent(
        "PreviewMouseLeftButtonUp", RoutingStrategy.Tunnel, typeof(RoutedEventHandler),   typeof(WindowControl)); 

// Provide CLR accessors for the event        
public event RoutedEventHandler MouseUp
{
  add { AddHandler(RoutedMouseUpEvent, value); }
  remove { RemoveHandler(RoutedMouseUpEvent, value); }
}

public addView(UserControl view)
{
WindowControl win = new WindowControl();
win.Content = view;
}

private void Grid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
  RoutedEventArgs newEventArgs = new RoutedEventArgs(MyParent.RoutedMouseUpEvent);
            RaiseEvent(newEventArgs);
}
}

The encapsulation of addView is necessary, should be no problem? The child is added via addView.
Grid_MouseLeftButtonUp is called.
The receiver looks like this (It is mvvm so there isn’t much):

public partial class ChildView : UserControl
{
 void UserControl_PreviewMouseLeftButtonUp(object sender, RoutedEventArgs args)
 {
    int i = 0; // The breakpoint is never called
 }
}

in the xaml

<Grid>
   <Border BorderBrush="black" BorderThickness="1" HorizontalAlignment="Center"   VerticalAlignment="Center" PreviewMouseLeftButtonUp="UserControl_PreviewMouseLeftButtonUp">
</Border>
</Grid>

If I forgot something please let me know.
The problem is, that the routed event does not reach UserControl_PreviewMouseLeftButtonUp

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:44:52+00:00Added an answer on June 14, 2026 at 2:44 pm

    This is not how tunneling routing strategy works. Tunneling means that the event will start from the root and go down the tree path to the calling control. For example if we have the following visual tree

    Window
    |
    |--> SomeUserControl
    |--> MyParent
         |
         |--> ChildView
    

    then if MyParent will raise a tunneling event, the tunneling event will visit:

    1. Window
    2. MyParent

    and NOT

    1. MyParent
    2. ChildView

    So to summarize, bubbling events will always start at the control raising the event and stop at the root of the visual tree, while tunneling events will start at the root of the visual tree and end at the control raising the event (exact same path, only reverse order).

    EDIT: You can read more about routed events in MSDN’s Routed Events Overview. It also has a nice image demonstrating this:

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've found a lot of example of this, but none with exactly what I'm
i found a lot of questions about resizing images in .NET and whatnot, but
This is my first time posting here, but I've found a lot of answers
I've found a lot of information on object oriented programming, but none of it
i found a lot of topics around placing buttons on navigation bar but none
Good day, I found a lot of topics about that, but, without a proper
I think this might be a fairly easy question. I found a lot of
I've found a lot of related questions (here and elsewhere), but haven't found this
OK - I have looked and looked and found a lot of examples but
I found a lot of helpful information on stackoverflow, but a tiny bit is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.