wpf Route Event Code Snippet

將下面內容保存爲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>
相關文章
相關標籤/搜索