开发者

How to declare a var of type delegate RoutedPropertyChangedEventHandler in WPF?

I can't find the syntax for declaring a property for my user control of type delegate RoutedProper开发者_运维技巧tyChangedEventHandler (like slider ValueChange handler)

http://msdn.microsoft.com/en-us/library/ms589771.aspx


You're trying to create an event:

public event RoutedPropertyChangedEventHandler MyEvent;

However, in order for it to work correctly, you need to create a routed event

public static readonly RoutedEvent TapEvent = EventManager.RegisterRoutedEvent(
    "Tap", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MyButtonSimple));

// Provide CLR accessors for the event
public event RoutedEventHandler Tap
{
        add { AddHandler(TapEvent, value); } 
        remove { RemoveHandler(TapEvent, value); }
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜