In a custom FrameworkElement (a Shape) I have:
public static readonly RoutedEvent DragDeltaEvent = EventManager.RegisterRoutedEvent("DragDelta", RoutingStrategy.Bubble, typeof(DragDeltaEventHandler), typeof(MyShape));
public event DragDeltaEventHandler DragDelta { add { AddHandler(DragDeltaEvent, value); } remove { RemoveHandler(DragDeltaEvent, value); } }
// xaml DataTemplate:
<local:MyShape DragDelta="MyShape_DragDelta" />
The AddHandler
above is not invoked when the shapes (in a DataTemplate) are created.
I never receive the event in code behind when I fire it in my shape by:
RaiseEvent(new DragDeltaEventArgs(...);