Skip to content

Instantly share code, notes, and snippets.

@JamestsaiTW
Last active October 2, 2022 15:16
Show Gist options
  • Save JamestsaiTW/3e51d9d07d8d1d67e75702db55abcd8b to your computer and use it in GitHub Desktop.
Save JamestsaiTW/3e51d9d07d8d1d67e75702db55abcd8b to your computer and use it in GitHub Desktop.
針對 CommunityToolkit.Mvvm 套件設計運用
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>nprop</Title>
<Shortcut>nprop</Shortcut>
<Description>使用 CommunityToolkit.Mvvm.ComponentModel 設計支援屬性和欄位程式碼片段</Description>
<Author>James Tsai</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>field</ID>
<ToolTip>欄位名稱</ToolTip>
<Default>myField</Default>
</Literal>
<Literal>
<ID>type</ID>
<ToolTip>屬性類型</ToolTip>
<Default>int</Default>
</Literal>
<Literal>
<ID>property</ID>
<ToolTip>屬性名稱</ToolTip>
<Default>MyProperty</Default>
</Literal>
</Declarations>
<Code Language="csharp"><![CDATA[private $type$ _$field$;
public $type$ $property$
{
get { return _$field$;}
set { SetProperty<$type$>(ref _$field$, value );}
}
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>實作 ICommand 程式碼片段</Title>
<Shortcut>swicmd</Shortcut>
<Description>針對使用 System.Windows.Input 設計繫結命令進行實作 ICommand 的程式碼片段</Description>
<Author>James Tsai</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>name</ID>
<ToolTip>Command 命名名稱</ToolTip>
<Default>MyNew</Default>
</Literal>
</Declarations>
<Code Language="csharp"><![CDATA[
public ICommand $name$Command
{
get
{
return new Command(() =>
{
$end$
});
}
}
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment