Xamarin.Forms: Bindable Property snippet for Visual Studio

Use bprop tab tab to generate commands in ViewModels with this snippet

The result of the snippet

Save the snippet file as {name}.snippet in Visual Studio’s folder: C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC#\Snippets\1033\Visual C#

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
			<Title>Bindable Property</Title>
			<Description>Xamarin BindableProperty declaration code snippet</Description>
					<ToolTip>The property's name</ToolTip>
					<ToolTip>The type of the property</ToolTip>
					<ToolTip>The default value of the property</ToolTip>
					<ToolTip>The binding mode of the property</ToolTip>
					<ToolTip>The property changed handler method</ToolTip>
					<ToolTip>The property changing handler method</ToolTip>
			<Code Language="csharp">
        public static readonly BindableProperty $PropertyName$Property = BindableProperty.Create(
                                        propertyName: nameof($PropertyName$),
                                        returnType: typeof($Type$),
                                        declaringType: typeof(View),
                                        defaultValue: $DefaultValue$,
                                        defaultBindingMode: BindingMode.$BindingMode$,
                                        propertyChanged: $PropertyChangedHandler$,
					propertyChanging: $PropertyChangingHandler$);

        public $Type$ $PropertyName$
            get { return ($Type$)GetValue($PropertyName$Property); }
            set { SetValue($PropertyName$Property, value); }
This content has 3 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.