In a simple WPF software application that I am writing, I would like to have a custom one Canvas.
I found questions like this one in StackOverflow, but could not find exactly this one, as well as an easy way to adapt another answer to my specific problem (note that I have little experience in WPF).
In my canvas, I would like it to have the following properties:
- the point (0, 0) is in the center
Canvas; - the x axis points to the right;
- the y axis points to the top;
- the point (1, 0) is approximately 1 inch to the right of the origin; and
- in each case, the mouse position is specified in the coordinate system defined above.
In this answer , Ray Burns offer a very simple solution for my first 3 points. It is trivial to change the code so that it had to deal with my point 4 (a change 1, and -1in the RenderTransformother constants).
However, this is a very simple and excellent solution for many tasks based on setting the width and height to 0 and centering the canvas on its container. Therefore, there is no canvas for capturing events such as a click, so this solution will not handle my fifth property.
What is the easiest way to achieve this? Inherit from Paneland do everything manually? Inherit from Canvas, intercept every event and change coordinates?