Silverlight 在画布上缩放

发布于 2024-10-09 02:39:21 字数 86 浏览 0 评论 0原文

我在画布上添加了一些折线,并注册了一个事件处理程序以在此画布上进行缩放,但缩放仅在鼠标恰好位于折线上方时才起作用。当鼠标位于画布上的其他位置时,如何进行缩放?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

神仙妹妹 2024-10-16 02:39:22

您在画布上设置了背景吗?鼠标事件通常仅在具有背景的元素上拾取。

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

顾挽 2024-10-16 02:39:22

要拾取事件,画布必须具有:

  1. 大小 - 默认情况下,画布没有大小(也许高度和宽度为 0 会更准确),尽管它可以具有超出其边界的子对象。将子对象放入画布(与网格或其他面板不同)不会自动调整面板大小以适应内容。
  2. 背景 - 可以是透明的(任何不透明度=“0”或背景=“#00FFFFFF”的背景)。

某些事件可能还需要将事件参数的 Handled 属性设置为 false,以允许事件从您单击的对象(在本例中为折线)级联到画布本身。听起来您没有遇到这个问题,但我会提到它,以防以后出现问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文