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); }
}
精彩评论