将下面内容保存为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>

相关文章:

  • 2022-12-23
  • 2021-09-09
  • 2021-05-24
  • 2021-09-21
  • 2022-01-13
  • 2021-09-16
  • 2022-01-18
猜你喜欢
  • 2022-12-23
  • 2022-01-03
  • 2021-06-24
  • 2022-12-23
  • 2022-02-12
  • 2021-09-15
  • 2022-12-23
相关资源
相似解决方案