鼠标点击放大 Silverlight 2.0

发布于 2024-09-29 11:38:04 字数 199 浏览 1 评论 0原文

我想在鼠标单击发生的地方精确地放大/缩小图像。整个图像应缩放,但当前视图应显示鼠标单击发生的部分,并且滚动条也应可用于查看其他部分。

我尝试使用滚动查看器并将图像控件放在其中。单击鼠标时,我使用 RenderTransform 并在每次用户单击“放大”时将比例增加 1。图像正在放大,但视图不在鼠标单击发生的位置。

请帮忙!

谢谢 赛伊

I would like to zoom in/out an image exactly where mouse click occurs. Whole image should be zoomed but current view should show the part where mouse click happened and scrollbar should be available for seeing other parts as well.

I tried using scrollviewer and placed my image control inside it. On mouse click am using RenderTransform and increasing the scale by 1 everytime user clicks for Zoom in.Image is getting zoomed-in but view is not at the place where mouse click occured.

Please help!

THanks
Sai

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

錯遇了你 2024-10-06 11:38:04

您需要设置 基于鼠标位置的 RenderTransformOrigin 属性。

根据 UIElement 边界框的左上角评估 RenderTransformOrigin 的值。

您需要将鼠标位置转换为图像的坐标,以获得正确的原点,并通过将位置除以图像的尺寸来标准化这些值,使它们位于 0 到 1 的范围内。

You need to set the RenderTransformOrigin property based on the mouse location.

Values for RenderTransformOrigin are evaluated against the top left corner of the bounding box for a UIElement.

You will need to convert your mouse location to the coordinates of the image to get the correct origin and normalize the values so that they are in the range 0 to 1 by dividing the position by the dimensions of the image.

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