2010-08-17 68 views
0

我想在wpf xaml中使用超链接。每当鼠标移过超链接时,它应该显示与该超链接相关的图像,当鼠标移开时图像应该消失。如何去使用绑定。我正在使用mvvm灯。OnmouseOver超链接显示图像在mvvm mvvm光wpf

请客气推荐。

感谢

+0

有什么建议吗?请告诉任何人? – Tarun 2010-08-18 08:56:58

回答

1

,你需要什么,如果你想在MVVM风格是达到这一目的的基本框架...

您将需要通过建立一个行为命令超链接来启动MouseEnter MouseLeave事件。

<Hyperlink NavigateUri="Uri"> 
    <i:Interaction.Triggers> 
     <i:EventTrigger EventName="MouseEnter"> 
      <Command:EventToCommand Command="HoverCommand" PassEventArgs="True" /> 
     </i:EventTrigger> 
    <i:Interaction.Triggers> 
    <i:Interaction.Triggers> 
     <i:EventTrigger EventName="MouseLeave"> 
      <Command:EventToCommand Command="HoverCommand" PassEventArgs="True" /> 
     </i:EventTrigger> 
    <i:Interaction.Triggers> 
    Link text. 
</Hyperlink> 

现在设置当它的DataContext不为空

命令上悬停控件的DataContext设置为图像的URI,休假设置的DataContext为null,将鼠标悬停在一个控制。

+1

您将哪些命名空间映射到“我:”以使这些工作起作用? – 2011-02-18 19:37:37

+0

xmlns:i =“clr-namespace:System.Windows.Interactivity; assembly = System.Windows.Interactivity” – 2012-12-07 14:47:56