Reputation: 14913
A very well known fact is that routed events only travel up or down the ancestry and not through all the elements.
But an equally known fact is that an event handler can be wired in the common parent of two disparate controls.
My questions is how, some pointers please.
I have XAML that looks like
<Grid Name="MainGrid">
<Listbox Name="lb1"/>
<Grid Name="InnerGrid">
<Listbox Name="lb2"/>
</Grid>
</Grid>
The Mouse Event handlers defined on "lb1" will not get fired as it gets "burried" under "InnerGrid". My question is how can I wrote some code in the "MainGrid" or somewhere else wherein the event handlers defined on "lb1" get fired. Or may be some other technique of achieveing this.
Many Thanks.
Upvotes: 0
Views: 1316
Reputation: 14256
I'm not sure exactly what you are asking, but it seems you want to be able to get called for events that have already been handled.
Try this:
In your code behind in the constructor after InitializeComponent()
, call
this.AddHandler(RoutedEvent, Delegate, bool);
Pass in the event (MouseDown
or etc), the delegate to call (something like lb1_MouseDown
), and then true
to indicate that you want to be called for events that have already been handled.
Upvotes: 1