Skip to content

Instantly share code, notes, and snippets.

@xeterixon
Last active January 23, 2017 09:25
Show Gist options
  • Save xeterixon/d1b33a3d5c6b40be8562 to your computer and use it in GitHub Desktop.
Save xeterixon/d1b33a3d5c6b40be8562 to your computer and use it in GitHub Desktop.
Xamarin Studio Code Snippet for creating the boilerplate code of a bindable property.
<!--
Download and copy this file to ~/Library/XamarinStudio-VERSION/Snippets
In a .cs file, type "bprop" and TAB to insert the code for a bindable property
-->
<?xml version="1.0" encoding="utf-8"?>
<CodeTemplates version="3.0">
<CodeTemplate version="2.0">
<Header>
<_Group>C#</_Group>
<Version />
<MimeType>text/x-csharp</MimeType>
<Shortcut>bprop</Shortcut>
<_Description>Bindable Property</_Description>
<TemplateType>Unknown</TemplateType>
</Header>
<Variables>
<Variable name="name">
<Default>PropertyName</Default>
</Variable>
<Variable name="type">
<Default>PropertyType</Default>
</Variable>
<Variable name="class">
<Default>Class</Default>
</Variable>
<Variable name="default">
<Default>DefaultValue</Default>
</Variable>
</Variables>
<Code><![CDATA[public static readonly BindableProperty $name$Property = BindableProperty.Create(nameof($name$),typeof($type$),typeof($class$),$default$);
public $type$ $name$
{
get{return ($type$)GetValue($name$Property);}
set{ SetValue( $name$Property, value);}
}
]]></Code>
</CodeTemplate>
</CodeTemplates>
@BartonCline
Copy link

It actually works better if
public $type$ $name$...
comes before
public static readonly BindableProperty $name$Property

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment