M.BindableProperty.Generator
0.4.1
See the version list below for details.
dotnet add package M.BindableProperty.Generator --version 0.4.1
NuGet\Install-Package M.BindableProperty.Generator -Version 0.4.1
<PackageReference Include="M.BindableProperty.Generator" Version="0.4.1" />
<PackageVersion Include="M.BindableProperty.Generator" Version="0.4.1" />
<PackageReference Include="M.BindableProperty.Generator" />
paket add M.BindableProperty.Generator --version 0.4.1
#r "nuget: M.BindableProperty.Generator, 0.4.1"
#:package M.BindableProperty.Generator@0.4.1
#addin nuget:?package=M.BindableProperty.Generator&version=0.4.1
#tool nuget:?package=M.BindableProperty.Generator&version=0.4.1
Maui.BindableProperty.Generator
Source generator that automatically transforms fields into BindableProperties that can be used in MAUI.
Installation
First, install NuGet. Then, install M.BindableProperty.Generator from the package manager console:
PM> Install-Package M.BindableProperty.Generator
Usage - Simple implementation
Just decorate field with the Bindable attribute.
using Maui.BindableProperty.Generator.Core;
public partial class CustomEntry : ContentView
{
[AutoBindable]
private string _placeholder;
}
the prevoius code will generate this:
public partial class CustomEntry
{
public static readonly Microsoft.Maui.Controls.BindableProperty PlaceholderProperty = Microsoft.Maui.Controls.BindableProperty.Create(nameof(Placeholder), typeof(string), typeof(CustomEntry), default(string));
public string Placeholder
{
get => (string)GetValue(PlaceholderProperty);
set => SetValue(PlaceholderProperty, value);
}
}
Usage - Custom property name
Just decorate field with the Bindable attribute.
using Maui.BindableProperty.Generator.Core;
public partial class CustomEntry : ContentView
{
[AutoBindable(PropertyName = "Text")]
private string _t;
}
the prevoius code will generate this:
public partial class CustomEntry
{
public static readonly Microsoft.Maui.Controls.BindableProperty TextProperty = Microsoft.Maui.Controls.BindableProperty.Create(nameof(Text), typeof(string), typeof(CustomEntry), default(string));
public string Text
{
get => (string)GetValue(TextProperty);
set => SetValue(TextProperty, value);
}
}
Usage - OnChanged method
Just decorate field with the Bindable attribute. The 'OnChanged' method must have only one parameter (must match the type of the field)
using Maui.BindableProperty.Generator.Core;
public partial class CustomEntry : ContentView
{
[AutoBindable(OnChanged = nameof(OnTextChanged))]
private string _text;
private void OnTextChanged(string newValue)
{
// Do stuff here
}
}
the prevoius code will generate this:
public partial class CustomEntry
{
public static readonly Microsoft.Maui.Controls.BindableProperty TextProperty = Microsoft.Maui.Controls.BindableProperty.Create(nameof(Text), typeof(string), typeof(CustomEntry), default(string));
public string Text
{
get => (string)GetValue(TextProperty);
set =>
{
SetValue(TextProperty, value);
this.OnTextChanged(value);
}
}
}
Project status
- ✅ Simple implementation - Done
- ✅ Custom property name - Done
- 🔲 Custom Parameters - In Progress
- ✅ OnChanged method - Done
- 🔲 Property Accessibility - Pending
Extra info
This repo is using part of the code of CodeWriter to generate the CSharp files, thanks to the author.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages (8)
Showing the top 5 NuGet packages that depend on M.BindableProperty.Generator:
| Package | Downloads |
|---|---|
|
The49.Maui.ContextMenu
.NET MAUI library for Android and iOS to open a native context menu on long press. |
|
|
Sm.Maui.BottomSheet
ModalBottomSheet view for .NET MAUI |
|
|
SimpleRatingControl.MAUI
Simple Rating Control for .NET MAUI |
|
|
Yang.Maui.Helper.Controls
Package Description |
|
|
DSoft.Maui.ContextMenu
.NET MAUI library for Android and iOS to open a native context menu on long press. |
GitHub repositories (4)
Showing the top 4 popular GitHub repositories that depend on M.BindableProperty.Generator:
| Repository | Stars |
|---|---|
|
VladislavAntonyuk/MauiSamples
.NET MAUI Samples
|
|
|
the49ltd/The49.Maui.BottomSheet
.NET MAUI library used to display pages as Bottom Sheets
|
|
|
nor0x/Dots
the 🙂 friendly .NET SDK manager
|
|
|
matt-goldman/MauiCleanTodos
Clean Architecture with ASP.NET Core, .NET MAUI and Blazor
|
| Version | Downloads | Last Updated |
|---|---|---|
| 0.11.1 | 176,218 | 6/28/2023 |
| 0.11.0 | 323 | 6/28/2023 |
| 0.10.0 | 6,181 | 3/28/2023 |
| 0.9.3 | 11,882 | 12/7/2022 |
| 0.9.2 | 14,318 | 11/15/2022 |
| 0.9.1 | 1,104 | 9/27/2022 |
| 0.9.0 | 1,419 | 8/30/2022 |
| 0.8.3 | 1,526 | 7/27/2022 |
| 0.8.2 | 4,378 | 7/4/2022 |
| 0.8.1 | 755 | 7/1/2022 |
| 0.8.0 | 748 | 6/29/2022 |
| 0.7.0 | 815 | 4/28/2022 |
| 0.6.0 | 724 | 4/28/2022 |
| 0.5.0 | 716 | 4/21/2022 |
| 0.4.1 | 692 | 4/14/2022 |
| 0.4.0 | 692 | 4/12/2022 |
| 0.3.3 | 706 | 4/1/2022 |
| 0.3.2 | 703 | 4/1/2022 |
| 0.3.0 | 962 | 4/1/2022 |
Bugfix - OnChanged method refactored to allow BindingPropertyChangedDelegate