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 VisualStudioVersion = 17.0.31611.283
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiApp1", "MauiApp1\MauiApp1.csproj", "{7657E17E-5DF9-42C5-89F0-6F1A3F3D5241}" 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 EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Model", "Model\Model.csproj", "{54AA1F79-DA85-4E12-8D6E-94A9C57E36DD}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Model", "Model\Model.csproj", "{54AA1F79-DA85-4E12-8D6E-94A9C57E36DD}"
EndProject EndProject

@ -3,39 +3,12 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiApp1.MainPage"> x:Class="MauiApp1.MainPage">
<ScrollView> <VerticalStackLayout Spacing="25" Padding="30" VerticalOptions="Center">
<VerticalStackLayout <Label Text="{Binding Nom}"/>
Spacing="25" <Label Text="{Binding Note}"/>
Padding="30,0" <Label Text="{Binding Description}"/>
VerticalOptions="Center"> <Button Text="Change Nounours"
Clicked="Button_Clicked"/>
<Image </VerticalStackLayout>
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>
</ContentPage> </ContentPage>

@ -1,24 +1,25 @@
namespace MauiApp1; using Model;
using System.Diagnostics;
namespace MauiApp1;
public partial class MainPage : ContentPage public partial class MainPage : ContentPage
{ {
int count = 0; 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é");
public MainPage()
{
InitializeComponent();
}
private void OnCounterClicked(object sender, EventArgs e)
{
count++;
if (count == 1) public MainPage()
CounterBtn.Text = $"Clicked {count} time"; {
else InitializeComponent();
CounterBtn.Text = $"Clicked {count} times"; 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" /> <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup>
</Project> </Project>

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

@ -1,15 +1,15 @@
using Android.App; using Android.App;
using Android.Runtime; using Android.Runtime;
namespace MauiApp1; namespace MauiApp1.Platforms.Android;
[Application] [Application]
public class MainApplication : MauiApplication public class MainApplication : MauiApplication
{ {
public MainApplication(IntPtr handle, JniHandleOwnership ownership) public MainApplication(IntPtr handle, JniHandleOwnership ownership)
: base(handle, 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