OnmouseOver 在超链接上显示 mvvm mvvm light wpf 中的图像
我想在 wpf xaml 中使用超链接。每当鼠标移到超链接上时,它都应该显示与该超链接相关的图像,当鼠标离开时,图像应该消失。如何使用绑定来解决这个问题。我正在使用 mvvm light。
请建议。
谢谢
I want to use hyperlink in wpf xaml. Whenever mouse comes over the hyperlink, it should show image related to that hyperlink and when mouse gets away the image should disappear. How to go about this using bindings. I am using mvvm light.
Kindly Suggest.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想以 MVVM 风格完成此任务,您需要的基本框架是...
您需要首先设置一个行为来命令超链接 MouseEnter MouseLeave 事件。
现在设置一个当其 DataContext 不为 null 时将悬停的控件
使用该命令将悬停时的控件 DataContext 设置为图像的 Uri,在离开时将 datacontext 设置为 null。
The basic framework of what you will need, if you want to accomplish this in an MVVM style is...
You will need to start by setting up a Behavior to Command the Hyperlinks MouseEnter MouseLeave events.
Now setup a control that will hover when the its DataContext is not null
Use the command to set the controls DataContext on hover to the Uri of the image, on Leave set the datacontext to null.