开发者

OnmouseOver on hyperlink showing image in mvvm mvvm light wpf

I want to use hyperlink in wpf xaml. When开发者_JAVA百科ever 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


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.

<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>

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜