Debut databinding:
continuous-integration/drone/push Build is passing Details

pull/2/head
Loris OBRY 2 years ago
parent e3af264da9
commit c91ea388ec

@ -4,6 +4,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
VisualStudioVersion = 17.0.31611.283
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiApp1", "MauiApp1\MauiApp1.csproj", "{7657E17E-5DF9-42C5-89F0-6F1A3F3D5241}"
ProjectSection(ProjectDependencies) = postProject
{54AA1F79-DA85-4E12-8D6E-94A9C57E36DD} = {54AA1F79-DA85-4E12-8D6E-94A9C57E36DD}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Model", "Model\Model.csproj", "{54AA1F79-DA85-4E12-8D6E-94A9C57E36DD}"
EndProject

@ -3,39 +3,12 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiApp1.MainPage">
<ScrollView>
<VerticalStackLayout
Spacing="25"
Padding="30,0"
VerticalOptions="Center">
<Image
Source="dotnet_bot.png"
SemanticProperties.Description="Cute dot net bot waving hi to you!"
HeightRequest="200"
HorizontalOptions="Center" />
<Label
Text="Hello, World!"
SemanticProperties.HeadingLevel="Level1"
FontSize="32"
HorizontalOptions="Center" />
<Label
Text="Welcome to .NET Multi-platform App UI"
SemanticProperties.HeadingLevel="Level2"
SemanticProperties.Description="Welcome to dot net Multi platform App U I"
FontSize="18"
HorizontalOptions="Center" />
<Button
x:Name="CounterBtn"
Text="Click me"
SemanticProperties.Hint="Counts the number of times you click"
Clicked="OnCounterClicked"
HorizontalOptions="Center" />
</VerticalStackLayout>
</ScrollView>
<VerticalStackLayout Spacing="25" Padding="30" VerticalOptions="Center">
<Label Text="{Binding Nom}"/>
<Label Text="{Binding Note}"/>
<Label Text="{Binding Description}"/>
<Button Text="Change Nounours"
Clicked="Button_Clicked"/>
</VerticalStackLayout>
</ContentPage>

@ -1,24 +1,25 @@
namespace MauiApp1;
using Model;
using System.Diagnostics;
namespace MauiApp1;
public partial class MainPage : ContentPage
{
int count = 0;
public MainPage()
{
InitializeComponent();
}
private void OnCounterClicked(object sender, EventArgs e)
{
count++;
public Carte MaCarte { get; private set; }
= new Carte("Villageois", "Il peut voter", "Soit attentif", null, "image", "Le villageois n'est pas une carte très aprécié");
if (count == 1)
CounterBtn.Text = $"Clicked {count} time";
else
CounterBtn.Text = $"Clicked {count} times";
public MainPage()
{
InitializeComponent();
BindingContext = MaCarte;
}
SemanticScreenReader.Announce(CounterBtn.Text);
}
void Button_Clicked(object sender, EventArgs e)
{
Debug.WriteLine($"Just before MaCarte modification: {MaCarte}");
MaCarte.Note = 5;
MaCarte.Description = "Une super carte !";
Debug.WriteLine($"Just after MaCarte modification: {MaCarte}");
}
}

@ -51,4 +51,8 @@
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup>
</Project>

@ -2,7 +2,7 @@
using Android.Content.PM;
using Android.OS;
namespace MauiApp1;
namespace MauiApp1.Platforms.Android;
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
public class MainActivity : MauiAppCompatActivity

@ -1,15 +1,15 @@
using Android.App;
using Android.Runtime;
namespace MauiApp1;
namespace MauiApp1.Platforms.Android;
[Application]
public class MainApplication : MauiApplication
{
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
: base(handle, ownership)
{
}
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
: base(handle, ownership)
{
}
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Loading…
Cancel
Save