Blend 4 Beta:如何更改图像源作为时间轴的一部分

发布于 2024-08-30 10:05:06 字数 346 浏览 2 评论 0原文

我正在尝试 Blend 4 beta,并寻找一种方法来做一件简单的事情:

  • 当鼠标悬停在图像上时, 图像应将其来源更改为不同的图像。 当 MouseLeave 发生时,图像会变回来。

知道我可以在源代码中完成此操作,但我正在寻找一种无需代码的方法来完成此操作,无需手动编码 xaml。

Blend 4 似乎是完美的选择。但我尝试使用启动故事的事件触发器或使用视觉状态来设置此设置,但 Blend 似乎没有“记住”图像源已更改。它记得我更改了图像的其他属性(例如可见性、比例等),但图像源是我所追求的。

这是混合中的错误,还是我做错了什么?

I'm trying out Blend 4 beta, and looking for a way to do a simple thing:

  • When a mouse is hovered on an image,
    the image should change its source to a different image.
    When the MouseLeave happens, the image changes back.

I know I can do it in source code, but I'm looking for a code free way to do it, without hand coding xaml.

Blend 4 seems like the perfect fit. But I've tried to set this using Event Triggers that start stories, or using Visual States, but Blend does not seem to "remember" that the image source has changed. It remembers me changing other properties of the image (such as visibility, scale etc..) but Image source is what I'm after.

Is this a bug in blend, or am I doing something wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

好久不见√ 2024-09-06 10:05:07

简单的方法:

首先,订阅图像鼠标进入和鼠标离开的事件,然后在此事件中

使用 image.setsource(new Uri(new image url)) 为每个事件设置图像源,

如果您遇到麻烦,我可以发布真实代码这里后者的

问候

easy way:

first, subscribe the events of your image mouse enter and mouse leave then in this events

use image.setsource(new Uri(new image url)) to set the image source for each event

if u have troubles i can post real code here latter

regards
Rui

浮光之海 2024-09-06 10:05:06

一种选择是创建自定义操作并将其附加到图像。它仍然涉及代码,但有点混合。

public class ImageSwitchAction : TriggerAction<Image>   
{
    public ImageSource TargetImage { get; set; }
    protected override void Invoke(object o)
    {
        AssociatedObject.Source = TargetImage;
    }
}

将类添加到项目并构建后,您可以将新行为拖动到时间轴中的任何图像对象,并在操作属性中配置触发器和 ImageSource。根据您的情况,为 MouseEnter 添加一项操作,为 MouseLeave 添加一项操作。

One option is creating a custom action and attaching it to the image. It still involves code, but is kinda blendy.

public class ImageSwitchAction : TriggerAction<Image>   
{
    public ImageSource TargetImage { get; set; }
    protected override void Invoke(object o)
    {
        AssociatedObject.Source = TargetImage;
    }
}

After adding the class to your project and building, you can drag the new behavior to any image objects in the timeline, and configure the trigger and ImageSource in the action properties. In your case, add one action for MouseEnter and one for MouseLeave.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文