Skip to content

Commit

Permalink
Updated Demo project. Updated readme file.
Browse files Browse the repository at this point in the history
  • Loading branch information
rrmanzano committed Jul 18, 2022
1 parent 292c2cd commit 0eac337
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 38 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

# Maui.BindableProperty.Generator

Source generator that automatically transforms fields into BindableProperties that can be used in MAUI.
Source generator that automatically transforms fields into BindableProperties that can be used in MAUI.
Are you looking for the Xamarin project? check this [link](https://github.com/rrmanzano/xamarin-bindableproperty-generator)

## Installation
First, [install NuGet](http://docs.nuget.org/docs/start-here/installing-nuget). Then, install [M.BindableProperty.Generator](https://www.nuget.org/packages/M.BindableProperty.Generator/) from the package manager console:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.BindableProperty.Generator.Demo.CustomControls.HeaderControl"
x:Name="this">
<VerticalStackLayout xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.BindableProperty.Generator.Demo.CustomControls.HeaderControl"
x:Name="this">

<ContentView.Resources>
<VerticalStackLayout.Resources>

<Style TargetType="{x:Type Label}">
<Setter Property="Margin" Value="0,10,0,0" />
</Style>

</ContentView.Resources>

<VerticalStackLayout>

<Label Text="FirstName"/>
<Entry
Text="{Binding Source={x:Reference this},Path=FirstName}"/>

<Label Text="LastName"/>
<Entry
Text="{Binding Source={x:Reference this},Path=LastName}" />

<Label Text="Birth date"/>
<DatePicker
Format="D"
Date="{Binding Source={x:Reference this},Path=BirthDate}" />

<Label Text="Country"/>
<Entry
Text="{Binding Source={x:Reference this},Path=Country}" />

<Label Text="Full Name : "/>
<Label
FontAttributes="Bold"
Text="{Binding Source={x:Reference this},Path=DisplayName}"/>

</VerticalStackLayout>
</ContentView>
</VerticalStackLayout.Resources>

<Label Text="FirstName"/>
<Entry
Text="{Binding Source={x:Reference this},Path=FirstName}"/>

<Label Text="LastName"/>
<Entry
Text="{Binding Source={x:Reference this},Path=LastName}" />

<Label Text="Birth date"/>
<DatePicker
Format="D"
Date="{Binding Source={x:Reference this},Path=BirthDate}" />

<Label Text="Country"/>
<Entry
Text="{Binding Source={x:Reference this},Path=Country}" />

<Label
Text="Full Name : " />
<Label
FontAttributes="Bold"
Text="{Binding Source={x:Reference this},Path=DisplayName}"
BackgroundColor="{Binding Source={x:Reference this},Path=BackgroundColor}"/>

</VerticalStackLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Maui.BindableProperty.Generator.Demo.CustomControls
{
public partial class HeaderControl : ContentView
public partial class HeaderControl : VerticalStackLayout
{
#pragma warning disable CS0169

Expand All @@ -21,8 +21,8 @@ public partial class HeaderControl : ContentView
[AutoBindable]
private readonly string? _displayName;

[AutoBindable(HidesUnderlyingProperty = true, DefaultValue = "Color.FromArgb(\"#bdbde6\")")]
private readonly Color? _backgroundColor;
[AutoBindable(HidesUnderlyingProperty = true, DefaultValue = "Color.FromArgb(\"#cc3340\")")]
private readonly Color _backgroundColor = Color.FromArgb("#cc3340");

#pragma warning restore CS0169

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void ProcessBodySetter(CodeWriter w)
public void ProcessImplementationLogic(CodeWriter w)
{
this.OnChangedProperty.GetValue<string>(methodName => {
var methodDefinition = @$"private static void __{methodName}(Microsoft.Maui.Controls.BindableObject bindable, object oldValue, object newValue)";
var methodDefinition = @$"private static void __{methodName}({AutoBindableConstants.FullNameMauiControls}.BindableObject bindable, object oldValue, object newValue)";
if (w.ToString().Contains(methodDefinition))
return default;
Expand Down

0 comments on commit 0eac337

Please sign in to comment.