ReSharper C# Live Template for Declaring Routed Event
Posted
by Bart Read
on Simple Talk
See other posts from Simple Talk
or by Bart Read
Published on Tue, 30 Nov 2010 14:46:14 GMT
Indexed on
2010/12/06
16:58 UTC
Read the original article
Hit count: 417
.NET
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!
© Simple Talk or respective owner