tags:

views:

23

answers:

1

How can I have have one element forward the mouse events to another element?

I would like to simulate a margin that forwards events to the content. In the following example, r1 is the margin and r2 is the content.

<DockPanel>
<Rectangle DockPanel.Dock='Left' Name="r1" MouseLeftButtonDown="r1Down"/>
<Rectangle Name="r2" MouseLeftButton="r2Down"/>
</DockPanel>

What I would like to do is

r1Down (object sender, object args)
{
  //raise event for r2 where mouse position.X = 0
}
+1  A: 

To simply "forward" the event to r2, you can do the following:

r1Down (object sender, object args)
{
  r2.RaiseEvent(args);
}

I'm not sure what you meant by "where mouse position.X = 0" in your comment though.

karmicpuppet