首页 > 其他 > 详细

VS代码片段

时间:2020-09-05 13:43:38      阅读:39      评论:0      收藏:0      [点我收藏+]

WPF

  • 注册依赖属性代码片段:propdpa.snippet
<?xml version="1.0" encoding="UTF-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>propdpa</Title>
      <Author>Microsoft Corporation</Author>
      <Description>注册附加的依赖属性.</Description>
      <Shortcut>propdpa</Shortcut>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Declarations>
        <Literal>
          <ID>propertyType</ID>
          <ToolTip>替换为属性的类型.</ToolTip>
          <Default>int</Default>
        </Literal>
        <Literal>
          <ID>propertyName</ID>
          <ToolTip>替换为属性的名称.</ToolTip>
          <Default>MyProperty</Default>
        </Literal>
        <Literal>
          <ID>defaultValue</ID>
          <ToolTip>替换为属性的默认值.</ToolTip>
          <Default>0</Default>
        </Literal>
         <Object>
          <ID>ownertype</ID>
          <Type>Control</Type>
          <ToolTip>替换为要添加此代码段的类的名称.</ToolTip>
          <Default>ownerclass</Default>
        </Object>
      </Declarations>
      <Code Language="csharp">
        <![CDATA[
          /// <summary>
          /// 
          /// </summary>
          public static readonly DependencyProperty $propertyName$Property = DependencyProperty.RegisterAttached("$propertyName$", typeof($propertyType$), typeof($ownertype$), new PropertyMetadata($defaultValue$));

          /// <summary>
          /// 
          /// </summary>
          /// <param name="element"></param>
          /// <param name="value"></param>
          public static void Set$propertyName$(DependencyObject element, $propertyType$ value)
          {
              element.SetValue($propertyName$Property, value);
          }

          /// <summary>
          /// 
          /// </summary>
          /// <param name="element"></param>
          /// <returns></returns>
          public static $propertyType$ Get$propertyName$(DependencyObject element)
          {
              return ($propertyType$)element.GetValue($propertyName$Property);
          }
          $end$]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>

VS代码片段

原文:https://www.cnblogs.com/wgx0428/p/13617661.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!