ReSharper C# Live Template for Declaring Routed Event
- by Bart Read
Here's another WPF ReSharper Live Template for you. This one is for declaring standalone routed events of any type. Again, it's pretty simple: #region $EVENTNAME$ Routed Event public static readonly RoutedEvent $EVENTNAME$Event = EventManager.RegisterRoutedEvent( "$EVENTNAME$", RoutingStrategy.$ROUTINGSTRATEGY$, typeof( $EVENTHANDLERDELEGATE$ ), typeof( $DECLARINGTYPE$ ) ); public event $EVENTHANDLERDELEGATE$ $EVENTNAME$ { add { AddHandler( $EVENTNAME$Event, value ); } remove { RemoveHandler( $EVENTNAME$Event, value ); } } protected virtual void On$EVENTNAME$() { RaiseEvent( new $EVENTARGSTYPE$( $EVENTNAME$Event, this ) ); $END$ } #endregion
Here are my previous posts along the same lines:
ReSharper C# Live Template for Read-Only Dependency Property and Routed Event Boilerplate
ReSharper C# Live Template for Dependency Property and Property Change Routed Event Boilerplate Code
Enjoy!
Technorati Tags: resharper,live template,c#,routed event,wpf,boilerplate,code generation