Event Bubbling on Click Event in Silverlight

11 Oct

A routed event is an event that traverses the object hierarchy from the element that triggers the event up to each of its parent objects. Events are bubbled up. But not all framework elements support routed events – the framework elements that support routed events are:

  • KeyDown
  • KeyUp
  • MouseEnter
  • MouseLeftButtonDown
  • MouseLeftButtonUp
  • MouseMove
  • BindingValidationError

Just for the fun of it, imagine that we put a button as content of another button. Both buttons have a click event. What will happen if we click the inner button? Will both click events be fired or just the click event for the inner button?

<Button Click=”OuterButton_Click”
Width=”200″ Height=”100″>
<Button Click=”InnerButton_Click”
Width=”150″ Height=”75″
Content=”Click Me” />
</Button>

Only our inner click event will be fired. Control specific events don’t bubble – including the click event for the button control. Why propagate an event through the tree, when it can be handled only by a specific type of controls?!

by xamlgeek.dk

One Response to “Event Bubbling on Click Event in Silverlight”

  1. surekha April 20, 2013 at 07:42 #

    please give more info for silverlight event bubbling with simple example.
    regards
    surekha

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: