Is it possible to set IsHitTestVisible to false only for right-click events?

Obviously, the direct answer to the question is “No,” but what is the best way for me to achieve this effect? To explain, there is a little background ...

I have an application that displays an image plus a couple of layers of overlay shapes on this image. All of them are placed in the Grid cell, overlapping each other, with the image at the bottom of the local z-order. For speed, blends are implemented as classes derived from FrameworkElement, and they create and manage their own visual effects.

Here is the main diagram (although exploded in 3D) of how the layers are located and what kind of interaction they have / need:


overlapped_controls.png http://www.afterbang.co.uk/mal/stackoverflow/overlapped_controls.png


As you can see, the upper caption should allow the user to drag a new rectangle anywhere in the image. To this end, I gave her a transparent background, acting like a plate of glass on which to draw. The obvious disadvantage of this is that it stops all mouse events that extend to the lower layers.

I would really like to just grab the left mouse button in the transparent area of ​​the top layer and let other events hit the layers further in the z-order.

Does the WPF-shaped template that I have to follow this kind of thing? Any best practice or technique?

I'm still pretty fresh for WPF, but I want to write a solution that matches the API setting. Thank.

+3
1

PreviewMouseDown , , LeftMouseDown , . PreviewMouseDown - , , .

, , , . PreviewMouseDown , , LeftMouseDown , , ..

+1

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


All Articles