WPF:如何获取ListView Item中图像的位置?
ListViewItem 包含一个缩略图,
当鼠标悬停在缩略图上时,我想显示一张大图像,
缩略图和大图像的中心应该相等,
有什么建议吗?
抱歉我的英语不好, 有一张关于我的想法的照片,也许你可以看到我说的: http://farm5.static.flickr.com/4100/4788840950_7d952a384c_b.jpg
ListViewItem Contain one thumbnail,
when the mouse over the thumbnail,I want to show a big Image,
the center should equal between thumbnail and big image,
any suggestion?
sorry about my poor English,
there is a photo about my idea, maybe you can see what I said:
http://farm5.static.flickr.com/4100/4788840950_7d952a384c_b.jpg
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以将大图像放在列表视图项中(例如在网格中),并使用 RenderTransform 将大图像缩放到完整尺寸,而无需更改列表视图的布局。
或者,如果您想自己完成这项工作,请使用 Visual.TransformToDescendant 或 Visual.TransformToAncestor
You can put the big image inside the list view item (in a grid for example) and use RenderTransform to scale the big image to full size without changing the layout of the list view.
Or, if you want to do the work yourself, use Visual.TransformToDescendant or Visual.TransformToAncestor
您应该实现 O'REILLY 出版的 Judith Bishop 书《C# 3.0 设计模式》中详细描述的
FlyWeight
模式。一旦实现了 FlyWeight 演示,其他工作就会很简单。然后,您只需在 DataTemplate 中引发鼠标悬停事件即可显示全尺寸图像。You should to implement a
FlyWeight
pattern described in details in Judith Bishop book C# 3.0 Design Patterns by O'REILLY publishing. Once you implement FlyWeight presentation, the other work will be simple. You then just have to on mouse hover event in DataTemplate raise to show your FullSize image.抱歉,我不太明白这个问题,但是您可以通过该方法获取用于将缩略图定位到任何视觉祖先的转换,
然后您可以使用该转换,调用
Transform()
方法来获取相对于AnyAncestorControl
(通常是页面/控件的根)的边界,并使用该bounds
变量来定位新的较大图像。华泰
Im sorry, I dont quite understand the question, but you can get the transform used to position the thumbnail against any visual ancestor via the method
then you can use that transform, call the
Transform()
method to get the bounds relative to theAnyAncestorControl
(which is usually your root of your page/control) and use thatbounds
variable to position your new larger image.HTH