开发者

Silverlight zoom on canvas

开发者 https://www.devze.com 2023-01-31 11:31 出处:网络
I added 开发者_运维问答some polylines on a canvas and registered an event handler for zoom on this canvas, but zooming only works when the mouse is exactly over the polyline. How can I make zooming wo

I added 开发者_运维问答some polylines on a canvas and registered an event handler for zoom on this canvas, but zooming only works when the mouse is exactly over the polyline. How can I make zooming work when the mouse is somewhere else on the canvas?


Have you set a background on your Canvas? Mouse events are generally only picked up on elements that have a background.


To pick up events a Canvas must have:

  1. A size - By default, a canvas has no size (perhaps a Height and Width of 0 would be more accurate), though it can have child objects that extend beyond its boundaries. Putting child objects into a Canvas (unlike a Grid or other Panel) does not automatically resize the panel to fit the content.
  2. A background - This can be transparent (Any Background with Opacity="0" or Background="#00FFFFFF").

Some events may also require that the Handled property of the event args be set to false to allow the event to cascade from the object you clicked (the Polyline in this case) to the Canvas itself. Doesn't sound like you're having that problem, but I mention it in case it becomes an issue later.

0

精彩评论

暂无评论...
验证码 换一张
取 消