将下面内容保存为snippet后缀文件,通过vs的代码片段管理工具导入即可,快捷键请按需修改:
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>创建路由事件</Title>
<Shortcut>revt</Shortcut>
<Description>创建route ev</Description>
<Author>虫子樱桃</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<ToolTip>属性类型</ToolTip>
<Default>EventHandler</Default>
</Literal>
<Literal>
<ID>RoutedEventName</ID>
<ToolTip>属性名</ToolTip>
<Default>MyEvent</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[ public event $type$ $RoutedEventName$
{
add{ AddHandler($RoutedEventName$Event, value); }
remove{ RemoveHandler($RoutedEventName$Event, value); }
} public static readonly RoutedEvent $RoutedEventName$Event=EventManager.RegisterRoutedEvent(
"$RoutedEventName$",RoutingStrategy.Bubble,typeof($type$),typeof(myclass));
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>