kr13
kr13

Reputation: 537

Panning the display area in WPF

The application will have a menu strip on top and the rest will display lines and shapes. I want to be able to drag and pan the main display area by clicking it and dragging it in any direction.

I am currently drawing items using pixel values (for example a line drawn from (1042,54)to(1240,104). But I think a monitor with a smaller resolution will not be able to display that object. That is why I want to be able to pan the display area.

The lines and shapes are currently being drawn on a gird that I placed inside the window.

Upvotes: 2

Views: 422

Answers (1)

ChrisF
ChrisF

Reputation: 137148

If you place the canvas inside a ScrollViewer then if the canvas is larger than the application window it will be displayed with scroll bars.

You can then address points on the canvas with values relative to the canvas rather than the screen.

Upvotes: 1

Related Questions