Click event for controls under other controls

I have two controls A and B. The B control is placed above A. When B is clicked, only the event with clicking on it fires, however I need to also click the A event to fire. Could this be implemented using routable events?

Here is a screenshot of the controls:

alt text http://www.imagebanana.com/img/hu5znv4/buttons.png

Of course, this case is just an example. I am looking for a general way to raise events on all controls under a mouse cursor / in one place. However, a concrete solution to this problem would also help me! Thanks so much for any hint!

+3
source share
1

, e.Handled true. . , WPF 4.

e.Handled , UIElement.AddHandler , boolean handledEventsToo click. , . Click , e.Handled true.

, .

<Grid>
    <Button VerticalAlignment="Center" HorizontalAlignment="Center" Click="Click1">
        <Button Width="100" Height="25" Margin="20" Click="Click2" />
    </Button>
</Grid>

private void Click1( object sender, RoutedEventArgs e )
{
    ( (Button)sender ).Background = new SolidColorBrush( Colors.Blue );
}

private void Click2( object sender, RoutedEventArgs e )
{
    ( (Button)sender ).Background = new SolidColorBrush( Colors.Red );
    //e.Handled = true; // uncomment to stop bubbling
}
+2

Source: https://habr.com/ru/post/1752638/


All Articles