Skip to content

Instantly share code, notes, and snippets.

@KristofferBerge
Forked from parth7676/bprop.snippet
Last active January 25, 2018 08:53
Show Gist options
  • Save KristofferBerge/abea88eda7f0d28d9b1e88bf5446033e to your computer and use it in GitHub Desktop.
Save KristofferBerge/abea88eda7f0d28d9b1e88bf5446033e to your computer and use it in GitHub Desktop.
Bindable Property Snippet for Xamarin Forms.
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Title>bpropc</Title>
<Author>Microsoft Corporation</Author>
<Description>Code snippet for an automatically implemented $name$Property
Language Version: C# 3.0 or higher</Description>
<HelpUrl>
</HelpUrl>
<Shortcut>bpropc</Shortcut>
</Header>
<Snippet>
<Declarations>
<Literal Editable="true">
<ID>name</ID>
<ToolTip>name</ToolTip>
<Default>name</Default>
<Function>
</Function>
</Literal>
<Literal Editable="true">
<ID>owner</ID>
<ToolTip>owner</ToolTip>
<Default>Owner</Default>
<Function>
</Function>
</Literal>
<Literal Editable="true">
<ID>type</ID>
<ToolTip>type</ToolTip>
<Default>Type</Default>
<Function>
</Function>
</Literal>
</Declarations>
<Code Language="csharp"><![CDATA[public static readonly BindableProperty $name$Property = BindableProperty.Create(
propertyName: "$name$",
returnType: typeof($type$),
declaringType: typeof($owner$),
defaultValue: default($type$),
propertyChanged: On$name$Changed
);
public $type$ $name$
{
get { return ($type$)GetValue($name$Property); }
set { SetValue($name$Property, value); }
}
private static void On$name$Changed(BindableObject bindable, object oldValue, object newValue){
throw new NotImplementedException();
}
$end$]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment