<?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>
原文:https://www.cnblogs.com/wgx0428/p/13617661.html