Skip to content

Instantly share code, notes, and snippets.

@osyyyS
Last active August 31, 2023 06:46
Show Gist options
  • Save osyyyS/f2eaaea1941a4e92e311c7df0ecaf6f4 to your computer and use it in GitHub Desktop.
Save osyyyS/f2eaaea1941a4e92e311c7df0ecaf6f4 to your computer and use it in GitHub Desktop.
Creates an observable property with a backing field.
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Observableproperty with Backing Field</Title>
<Description>Creates a observable property with a backing field.</Description>
<Shortcut>bindableProp</Shortcut>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>Type</ID>
<ToolTip>Property type</ToolTip>
<Default>bool</Default>
</Literal>
<Literal>
<ID>PropertyName</ID>
<ToolTip>Property name</ToolTip>
<Default>IsBusy</Default>
</Literal>
<Literal>
<ID>FieldName</ID>
<ToolTip>Backing field name</ToolTip>
<Default>isBusy</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[public $Type$ $PropertyName$ { get => $FieldName$; set => SetProperty(ref $FieldName$, value); }
private $Type$ $FieldName$;]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment