悬停时放大图像缩略图
谁能给我一些关于如何在 Silverlight 中实现一个控件的建议,该控件显示图像缩略图,当鼠标悬停在该缩略图上时,将其放大到更大的尺寸?
Could anyone offer me some advice on how I might go about implementing a control in Silverlight that displays image thumbnails that when hovered over, enlarge it to a bigger size?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我对按钮做了类似的事情。这是代码 - 我相信您可以轻松地调整它以使用图像。请注意,我从未真正发布过这段代码;这只是我学习Silverlight时的一个实验。不要将其视为最佳实践的示例。
XAML:
代码:
I did something similar for a button. Here is the code for that - I'm sure you can adapt it easily to work with an image instead. Note that I never actually released this code; it was just an experiment when I was learning Silverlight. Don't take it as an example of best practise.
XAML:
Code:
只要您的控件具有 MouseOver 状态的 VisualState,您就可以使用
DoubleAnimation
(或DoubleAnimationUsingKeyframes
)来执行 ScaleTransform 控件上。为缩略图/图像控件创建不同的 VisualState(在 VisualStateGroup 内)将为您省去在后面的代码中连接事件的麻烦。您还可以在 Blend 中直观地定义不同的缩放比例,这是一个很好的功能。
As long as your control has a VisualState for the MouseOver state, you can use a
DoubleAnimation
(orDoubleAnimationUsingKeyframes
) to do a ScaleTransform on the control.Creating the different VisualStates (inside a VisualStateGroup) for your thumbnail/image control will save you the trouble of having to wire your events in the code behind. You'll also be able to define the different scaling visually in Blend which is a nice feature to have.
此页面 - 鱼眼菜单一个与你想要的类似的例子。由于某种原因,尽管我安装了 Silverlight,但它没有显示 Silverlight 版本。这可能与它在 Silverlight 2 中有关。
This page - Fish Eye Menu has an example that does something similar to what you want. For some reason it's not displaying the Silverlight version despite me having Silverlight installed. It might be something to do with it being in Silverlight 2.