本文介绍了自定义RoutedEvent作为EventTrigger的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有自己的造型课

public sealed class MirrorTile : Shape

在这个课程中,我添加了事件

and in this class I added the event

public static readonly RoutedEvent SelectedEnterEvent = EventManager.RegisterRoutedEvent("SelectedEnter", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MirrorTile));

public event RoutedEventHandler SelectedEnter
{
    add
    {
        this.AddHandler(SelectedEnterEvent, value);
    }

    remove
    {
        this.RemoveHandler(SelectedEnterEvent, value);
    }
}

并希望以这种方式使用

<shapes:MirrorTile>
    <shapes:MirrorTile.Triggers>
        <EventTrigger RoutedEvent="SelectedEnter">
            <BeginStoryboard Storyboard="{StaticResource SelectShape}"/>
        </EventTrigger>
    </shapes:MirrorTile.Triggers>
</shapes:MirrorTile>

在启动后,我得到一个例外:{"RoutedEventConverter cannot convert from System.String."}

After starup I get the exception:{"RoutedEventConverter cannot convert from System.String."}

我在做什么错了,我该如何解决这个问题?

What I'm doing wrong and how can I fix this problem?

推荐答案

<EventTrigger RoutedEvent="shapes:MirrorTile.SelectedLeave">

名称空间也丢失了.

这篇关于自定义RoutedEvent作为EventTrigger的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 14:22