Silverlight 在画布上缩放
我在画布上添加了一些折线,并注册了一个事件处理程序以在此画布上进行缩放,但缩放仅在鼠标恰好位于折线上方时才起作用。当鼠标位于画布上的其他位置时,如何进行缩放?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您在画布上设置了背景吗?鼠标事件通常仅在具有背景的元素上拾取。
Have you set a background on your Canvas? Mouse events are generally only picked up on elements that have a background.
要拾取事件,画布必须具有:
某些事件可能还需要将事件参数的 Handled 属性设置为 false,以允许事件从您单击的对象(在本例中为折线)级联到画布本身。听起来您没有遇到这个问题,但我会提到它,以防以后出现问题。
To pick up events a Canvas must have:
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.