BindableProperty.Fody 0.1.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package BindableProperty.Fody --version 0.1.3                
NuGet\Install-Package BindableProperty.Fody -Version 0.1.3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BindableProperty.Fody" Version="0.1.3">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BindableProperty.Fody --version 0.1.3                
#r "nuget: BindableProperty.Fody, 0.1.3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install BindableProperty.Fody as a Cake Addin
#addin nuget:?package=BindableProperty.Fody&version=0.1.3

// Install BindableProperty.Fody as a Cake Tool
#tool nuget:?package=BindableProperty.Fody&version=0.1.3                

Xamarin.BindableProperty.Fody

An assembly weaver, based on Fody, that automatically transforms plain auto-implemented properties into BindableProperties that can be used in Xamarin Forms.

Installation

Add this nuget package to your project. Then, add a file called FodyWeavers.xml in your project root (build action must be set to Content), and write the following inside:

<?xml version="1.0" encoding="utf-8"?>
<Weavers>
    <BindableProperty />
</Weavers>

See the Fody documentation for more info on the FodyWeavers.xml file.

Usage

Just decorate an auto-implemented get/set property with the Bindable attribute.

For example, this:

public class MyButton : Xamarin.Forms.Button
{
    [Bindable]
    public string FontFamily { get; set; }
}

will become like this:

public class MyButton : Xamarin.Forms.Button
{
    public static readonly BindableProperty FontFamilyProperty = BindableProperty.Create(nameof(FontFamily), typeof(string), typeof(Button), null, null);
    public string FontFamily { get { return (string)GetValue(FontFamilyProperty); } set { SetValue(FontFamilyProperty, value); } }
}

The public static readonly XxxProperty is automatically generated if not present. The getter and setter methods are automatically implemented with GetValue(...) and SetValue(...) methods, respectively. The Bindable attribute is removed from the resulting dll.

If you want some piece of code to be called whenever the property value changes, simply add a void OnXxxChanged method, where Xxx is the name of the property. It will be registered on the ValueChanged delegate in the BindableProperty.Create method:

public class MyButton : Xamarin.Forms.Button
{
    [Bindable]
    public string FontFamily { get; set; }
    
    private void OnFontFamilyChanged(string newValue) { 
        //do stuff here
        Console.WriteLine("Property value is changed");
    }
}

The OnXxxChanged method must have only one parameter (whose type must match the type of the property) that will contain the new value. The OnXxxChanged method can be private or public as well.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.4 is compatible.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 was computed.  netstandard2.1 was computed. 
.NET Framework net452 is compatible.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.6 6,004 3/29/2019
0.1.5 959 11/6/2018
0.1.4 716 10/28/2018
0.1.3 780 9/22/2018
0.1.2 795 9/21/2018