visual studit 代码片段及快捷键编辑
导入代码片段 工具->代码片段管理->选择语言->添加
2.代码片段制作 如下图事例
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Define a property for a view model class</Title>
<Shortcut>vmprop</Shortcut>
<Description>Code snippet for a property for a view model class</Description>
<Author>CatenaLogic</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>description</ID>
<ToolTip>Description of the property</ToolTip>
<Default>Gets or sets the property value</Default>
</Literal>
<Literal>
<ID>name</ID>
<ToolTip>Name of the property</ToolTip>
<Default>name</Default>
</Literal>
<Literal>
<ID>type</ID>
<ToolTip>Type of the property</ToolTip>
<Default>string</Default>
</Literal>
<Literal>
<ID>defaultvalue</ID>
<ToolTip>Default value of the property</ToolTip>
<Default>null</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[/// <summary>
/// $description$.
/// </summary>
public $type$ $name$
{
get { return GetValue<$type$>($name$Property); }
set { SetValue($name$Property, value); }
}
public static readonly PropertyData $name$Property = RegisterProperty("$name$", typeof($type$), $defaultvalue$);
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
- 主要字段及功能点说明
- <header>
- <Title> 标题及说明
- <Shortcut> 快捷指令
- <Snippet>
- <Literal> 变量定义区域 用于代码生成后统一修改
- <ID> 变量名称 关键
- <ToolTip> 变量说明
- <Default> 默认值
- <Literal> 变量定义区域 用于代码生成后统一修改
- <Code Language="csharp"> 自定义代码区域
- $type$ 使用变量代替可以编辑代码片段
代码片段制作完成 程序使用内使用效果如下
连续按下2次TAB键效果如下,修改变量后自动替换所有区域
个人常用代码片段保存 MVVM部分
dataprop
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Define a property for the ModelBase class</Title>
<Shortcut>dataprop</Shortcut>
<Description>Code snippet for a property for the ModelBase class</Description>
<Author>CatenaLogic</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>description</ID>
<ToolTip>Description of the property</ToolTip>
<Default>Gets or sets the property value</Default>
</Literal>
<Literal>
<ID>name</ID>
<ToolTip>Name of the property</ToolTip>
<Default>name</Default>
</Literal>
<Literal>
<ID>type</ID>
<ToolTip>Type of the property</ToolTip>
<Default>type</Default>
</Literal>
<Literal>
<ID>defaultvalue</ID>
<ToolTip>Default value of the property</ToolTip>
<Default>null</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[/// <summary>
/// $description$.
/// </summary>
public $type$ $name$
{
get { return GetValue<$type$>($name$Property); }
set { SetValue($name$Property, value); }
}
/// <summary>
/// Register the $name$ property so it is known in the class.
/// </summary>
public static readonly PropertyData $name$Property = RegisterProperty("$name$", typeof($type$), $defaultvalue$);]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
datapropchanged
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Define a property with a property changed callback for the ModelBase class</Title>
<Shortcut>datapropchanged</Shortcut>
<Description>Code snippet for a property with a property changed callback for the ModelBase class</Description>
<Author>CatenaLogic</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>description</ID>
<ToolTip>Description of the property</ToolTip>
<Default>Gets or sets the property value</Default>
</Literal>
<Literal>
<ID>name</ID>
<ToolTip>Name of the property</ToolTip>
<Default>name</Default>
</Literal>
<Literal>
<ID>type</ID>
<ToolTip>Type of the property</ToolTip>
<Default>type</Default>
</Literal>
<Literal>
<ID>defaultvalue</ID>
<ToolTip>Default value of the property</ToolTip>
<Default>defaultvalue</Default>
</Literal>
<Literal>
<ID>ownerclass</ID>
<ToolTip>The owning class of this property. Typically the class that it is declared in.</ToolTip>
<Function>ClassName()</Function>
<Default>ClassNamePlaceholder</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[/// <summary>
/// $description$.
/// </summary>
public $type$ $name$
{
get { return GetValue<$type$>($name$Property); }
set { SetValue($name$Property, value); }
}
/// <summary>
/// Register the $name$ property so it is known in the class.
/// </summary>
public static readonly PropertyData $name$Property = RegisterProperty("$name$", typeof($type$), $defaultvalue$, (sender, e) => (($ownerclass$)sender).On$name$Changed());
/// <summary>
/// Called when the $name$ property has changed.
/// </summary>
private void On$name$Changed()
{
// TODO: Implement logic
}]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
model
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Define a new instance of the ModelBase class</Title>
<Shortcut>model</Shortcut>
<Description>Code snippet for a property for the ModelBase class</Description>
<Author>CatenaLogic</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>name</ID>
<ToolTip>Name of the class</ToolTip>
<Default>name</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[/// <summary>
/// $name$ model which fully supports serialization, property changed notifications,
/// backwards compatibility and error checking.
/// </summary>
#if !SILVERLIGHT
[Serializable]
#endif
public class $name$ : ModelBase
{
#region Fields
#endregion
#region Constructors
/// <summary>
/// Initializes a new object from scratch.
/// </summary>
public $name$() { }
#if !SILVERLIGHT
/// <summary>
/// Initializes a new object based on <see cref="SerializationInfo"/>.
/// </summary>
/// <param name="info"><see cref="SerializationInfo"/> that contains the information.</param>
/// <param name="context"><see cref="StreamingContext"/>.</param>
protected $name$(SerializationInfo info, StreamingContext context)
: base(info, context) { }
#endif
#endregion
#region Properties
// TODO: Define your custom properties here using the modelprop code snippet
#endregion
#region Methods
/// <summary>
/// Validates the field values of this object. Override this method to enable
/// validation of field values.
/// </summary>
/// <param name="validationResults">The validation results, add additional results to this list.</param>
protected override void ValidateFields(List<IFieldValidationResult> validationResults)
{
}
/// <summary>
/// Validates the field values of this object. Override this method to enable
/// validation of field values.
/// </summary>
/// <param name="validationResults">The validation results, add additional results to this list.</param>
protected override void ValidateBusinessRules(List<IBusinessRuleValidationResult> validationResults)
{
}
#endregion
}]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
modelprop
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Define a property for the ModelBase class</Title>
<Shortcut>modelprop</Shortcut>
<Description>Code snippet for a property for the ModelBase class</Description>
<Author>CatenaLogic</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>description</ID>
<ToolTip>Description of the property</ToolTip>
<Default>Gets or sets the property value</Default>
</Literal>
<Literal>
<ID>name</ID>
<ToolTip>Name of the property</ToolTip>
<Default>name</Default>
</Literal>
<Literal>
<ID>type</ID>
<ToolTip>Type of the property</ToolTip>
<Default>type</Default>
</Literal>
<Literal>
<ID>defaultvalue</ID>
<ToolTip>Default value of the property</ToolTip>
<Default>null</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[/// <summary>
/// $description$.
/// </summary>
public $type$ $name$
{
get { return GetValue<$type$>($name$Property); }
set { SetValue($name$Property, value); }
}
/// <summary>
/// Register the $name$ property so it is known in the class.
/// </summary>
public static readonly PropertyData $name$Property = RegisterProperty("$name$", typeof($type$), $defaultvalue$);]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
modelpropchanged
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Define a property with a property changed callback for the ModelBase class</Title>
<Shortcut>modelpropchanged</Shortcut>
<Description>Code snippet for a property with a property changed callback for the ModelBase class</Description>
<Author>CatenaLogic</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>description</ID>
<ToolTip>Description of the property</ToolTip>
<Default>Gets or sets the property value</Default>
</Literal>
<Literal>
<ID>name</ID>
<ToolTip>Name of the property</ToolTip>
<Default>name</Default>
</Literal>
<Literal>
<ID>type</ID>
<ToolTip>Type of the property</ToolTip>
<Default>type</Default>
</Literal>
<Literal>
<ID>defaultvalue</ID>
<ToolTip>Default value of the property</ToolTip>
<Default>defaultvalue</Default>
</Literal>
<Literal>
<ID>ownerclass</ID>
<ToolTip>The owning class of this property. Typically the class that it is declared in.</ToolTip>
<Function>ClassName()</Function>
<Default>ClassNamePlaceholder</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[/// <summary>
/// $description$.
/// </summary>
public $type$ $name$
{
get { return GetValue<$type$>($name$Property); }
set { SetValue($name$Property, value); }
}
/// <summary>
/// Register the $name$ property so it is known in the class.
/// </summary>
public static readonly PropertyData $name$Property = RegisterProperty("$name$", typeof($type$), $defaultvalue$, (sender, e) => (($ownerclass$)sender).On$name$Changed());
/// <summary>
/// Called when the $name$ property has changed.
/// </summary>
private void On$name$Changed()
{
// TODO: Implement logic
}]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
vm
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Define a new view model class</Title>
<Shortcut>vm</Shortcut>
<Description>Code snippet for a new view model class</Description>
<Author>CatenaLogic</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>name</ID>
<ToolTip>Name of the view model</ToolTip>
<Default>name</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[/// <summary>
/// $name$ view model.
/// </summary>
public class $name$ViewModel : ViewModelBase
{
#region Fields
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="$name$ViewModel"/> class.
/// </summary>
public $name$ViewModel ()
{
}
#endregion
#region Properties
/// <summary>
/// Gets the title of the view model.
/// </summary>
/// <value>The title.</value>
public override string Title { get { return "View model title"; } }
// TODO: Register models with the vmpropmodel codesnippet
// TODO: Register view model properties with the vmprop or vmpropviewmodeltomodel codesnippets
#endregion
#region Commands
// TODO: Register commands with the vmcommand or vmcommandwithcanexecute codesnippets
#endregion
#region Methods
#endregion
}]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
vmcommand
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Define a command for a view model class</Title>
<Shortcut>vmcommand</Shortcut>
<Description>Code snippet for a command for a view model class</Description>
<Author>CatenaLogic</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>name</ID>
<ToolTip>Name of the command</ToolTip>
<Default>MyAction</Default>
</Literal>
<Literal>
<ID>type</ID>
<ToolTip>Type of the argument</ToolTip>
<Default>type</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[/// <summary>
/// Gets the $name$ command.
/// </summary>
public ICatelCommand $name$Command { get { return new Command(On$name$CommandExecute); } }
private void On$name$CommandExecute()
{
$end$
}]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
vmcommandwitharg
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Define a command for a view model class with argument</Title>
<Shortcut>vmcommandwitharg</Shortcut>
<Description>Code snippet for a command for a view model class</Description>
<Author>CatenaLogic</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>name</ID>
<ToolTip>Name of the command</ToolTip>
<Default>MyAction</Default>
</Literal>
<Literal>
<ID>type</ID>
<ToolTip>Type of the argument</ToolTip>
<Default>RoutedEventArgs</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[/// <summary>
/// Gets the $name$ command.
/// </summary>
public ICatelCommand $name$Command { get { return new Command<$type$>(On$name$CommandExecute); } }
private void On$name$CommandExecute($type$ e)
{
$end$
}]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
vmcommandwithcanexecute
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Define a command with a can execute method for a view model class</Title>
<Shortcut>vmcommandwithcanexecute</Shortcut>
<Description>Code snippet for a command with a can execute method for a view model class</Description>
<Author>CatenaLogic</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>name</ID>
<ToolTip>Name of the command</ToolTip>
<Default>MyAction</Default>
</Literal>
<Literal>
<ID>type</ID>
<ToolTip>Type of the property</ToolTip>
<Default>type</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[/// <summary>
/// Gets the $name$ command.
/// </summary>
public ICatelCommand $name$Command { get { return new Command(On$name$CommandExecute, On$name$CommandCanExecute); } }
private void On$name$CommandExecute()
{
$end$
}
private bool On$name$CommandCanExecute()
{
return true;
}]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
vmcommandwithvalidationsummary
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Define a command linked to a validation summary for a view model class</Title>
<Shortcut>vmcommandwithvalidationsummary</Shortcut>
<Description>Code snippet for a command linked to a validation summary for a view model class</Description>
<Author>CatenaLogic</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>name</ID>
<ToolTip>Name of the command</ToolTip>
<Default>name</Default>
</Literal>
<Literal>
<ID>type</ID>
<ToolTip>Type of the property</ToolTip>
<Default>type</Default>
</Literal>
<Literal>
<ID>summary</ID>
<ToolTip>Name of the summary</ToolTip>
<Default>summary</Default>
</Literal>
<Literal>
<ID>tag</ID>
<ToolTip>Tag of the validation</ToolTip>
<Default>tag</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[/// <summary>
/// Gets the $name$ command.
/// </summary>
public Command $name$ { get; private set; }
// TODO: Move code below to constructor
$name$ = CommandHelper.CreateCommand(On$name$Execute, () => $summary$ValidationSummary);
// TODO: Move code above to constructor
/// <summary>
/// Method to invoke when the $name$ command is executed.
/// </summary>
private void On$name$Execute()
{
// TODO: Handle command logic here
}
/// <summary>
/// Validation summary for validation with the tag '$tag$' that is automatically updated.
/// </summary>
[ValidationToViewModel(Tag = "$tag$")]
public IValidationSummary $summary$ValidationSummary { get; set; }]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
vmprop
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Define a property for a view model class</Title>
<Shortcut>vmprop</Shortcut>
<Description>Code snippet for a property for a view model class</Description>
<Author>CatenaLogic</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>description</ID>
<ToolTip>Description of the property</ToolTip>
<Default>Gets or sets the property value</Default>
</Literal>
<Literal>
<ID>name</ID>
<ToolTip>Name of the property</ToolTip>
<Default>name</Default>
</Literal>
<Literal>
<ID>type</ID>
<ToolTip>Type of the property</ToolTip>
<Default>string</Default>
</Literal>
<Literal>
<ID>defaultvalue</ID>
<ToolTip>Default value of the property</ToolTip>
<Default>null</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[/// <summary>
/// $description$.
/// </summary>
public $type$ $name$
{
get { return GetValue<$type$>($name$Property); }
set { SetValue($name$Property, value); }
}
public static readonly PropertyData $name$Property = RegisterProperty("$name$", typeof($type$), $defaultvalue$);
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
vmpropchanged
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Define a property with a property changed callback for a view model class</Title>
<Shortcut>vmpropchanged</Shortcut>
<Description>Code snippet for a property with a property changed callback for a view model class</Description>
<Author>CatenaLogic</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>description</ID>
<ToolTip>Description of the property</ToolTip>
<Default>Gets or sets the property value</Default>
</Literal>
<Literal>
<ID>name</ID>
<ToolTip>Name of the property</ToolTip>
<Default>name</Default>
</Literal>
<Literal>
<ID>type</ID>
<ToolTip>Type of the property</ToolTip>
<Default>type</Default>
</Literal>
<Literal>
<ID>defaultvalue</ID>
<ToolTip>Default value of the property</ToolTip>
<Default>null</Default>
</Literal>
<Literal>
<ID>ownerclass</ID>
<ToolTip>The owning class of this property. Typically the class that it is declared in.</ToolTip>
<Function>ClassName()</Function>
<Default>ClassNamePlaceholder</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[/// <summary>
/// $description$.
/// </summary>
public $type$ $name$
{
get { return GetValue<$type$>($name$Property); }
set { SetValue($name$Property, value); }
}
/// <summary>
/// Register the $name$ property so it is known in the class.
/// </summary>
public static readonly PropertyData $name$Property = RegisterProperty("$name$", typeof($type$), $defaultvalue$, (sender, e) => (($ownerclass$)sender).On$name$Changed());
/// <summary>
/// Called when the $name$ property has changed.
/// </summary>
private void On$name$Changed()
{
// TODO: Implement logic
}]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
vmpropmodel
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Define a property as a model for a view model class</Title>
<Shortcut>vmpropmodel</Shortcut>
<Description>Code snippet for a property as a model for a view model class</Description>
<Author>CatenaLogic</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>description</ID>
<ToolTip>Description of the property</ToolTip>
<Default>Gets or sets the property value</Default>
</Literal>
<Literal>
<ID>name</ID>
<ToolTip>Name of the property</ToolTip>
<Default>name</Default>
</Literal>
<Literal>
<ID>type</ID>
<ToolTip>Type of the property</ToolTip>
<Default>type</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[/// <summary>
/// $description$.
/// </summary>
[Model]
public $type$ $name$
{
get { return GetValue<$type$>($name$Property); }
private set { SetValue($name$Property, value); }
}
/// <summary>
/// Register the $name$ property so it is known in the class.
/// </summary>
public static readonly PropertyData $name$Property = RegisterProperty("$name$", typeof($type$));]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
vmpropviewmodeltomodel
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Define a property as a view model to model mapping for a view model class</Title>
<Shortcut>vmpropviewmodeltomodel</Shortcut>
<Description>Code snippet for a property as a view model to model mapping for a view model class</Description>
<Author>CatenaLogic</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>description</ID>
<ToolTip>Description of the property</ToolTip>
<Default>Gets or sets the property value</Default>
</Literal>
<Literal>
<ID>modelname</ID>
<ToolTip>Name of the property that holds the model and is decorated with the Model attribute</ToolTip>
<Default>model</Default>
</Literal>
<Literal>
<ID>name</ID>
<ToolTip>Name of the property</ToolTip>
<Default>name</Default>
</Literal>
<Literal>
<ID>type</ID>
<ToolTip>Type of the property</ToolTip>
<Default>type</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[/// <summary>
/// $description$.
/// </summary>
[ViewModelToModel("$modelname$")]
public $type$ $name$
{
get { return GetValue<$type$>($name$Property); }
set { SetValue($name$Property, value); }
}
/// <summary>
/// Register the $name$ property so it is known in the class.
/// </summary>
public static readonly PropertyData $name$Property = RegisterProperty("$name$", typeof($type$));]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
以上 其他有用代码片段 持续更新