ajout du dataBinding

pull/13/head
Antoine PEREDERII 2 years ago
parent e79a1f802a
commit 01ee4d181b

@ -4,8 +4,12 @@
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Banquale.Views" xmlns:local="clr-namespace:Banquale.Views"
Shell.FlyoutBehavior="Disabled" Shell.NavBarIsVisible="True"
Shell.NavBarIsVisible="False"> Shell.NavBarHasShadow="True"
NavigationPage.HasNavigationBar="True"
NavigationPage.HasBackButton="True"
NavigationPage.BackButtonTitle="Retour"
Title="Page">
<TabBar> <TabBar>
@ -21,5 +25,7 @@
</TabBar> </TabBar>
<!--<NavigationPage.BackButtonTitle
-->
</Shell> </Shell>

@ -16,6 +16,10 @@ namespace Banquale.Model
return true; return true;
} }
public Client GetClient(int place) {
return ListeClients[place];
}
public void Donnee() public void Donnee()
{ {
Client Client1= new Client("Jacques", "Morice", "J'aimeLesFrites"); Client Client1= new Client("Jacques", "Morice", "J'aimeLesFrites");

@ -4,7 +4,9 @@
xmlns:local="clr-namespace:Banquale.Views" xmlns:local="clr-namespace:Banquale.Views"
x:Class="Banquale.Views.BalancePage" x:Class="Banquale.Views.BalancePage"
Title="BalancePage" Title="BalancePage"
NavigationPage.HasBackButton="True"
> >
<Grid RowDefinitions="auto, *"> <Grid RowDefinitions="auto, *">
<Grid BackgroundColor="Beige" <Grid BackgroundColor="Beige"
HorizontalOptions="Center" HorizontalOptions="Center"
@ -17,6 +19,8 @@
Margin="30" Margin="30"
> >
<Button Clicked="OnButtonClicked" />
<Label <Label
Text="Compte Professionnel" Text="Compte Professionnel"
HorizontalOptions="Center" HorizontalOptions="Center"

@ -7,5 +7,13 @@ public partial class BalancePage : ContentPage
public BalancePage() public BalancePage()
{ {
InitializeComponent(); InitializeComponent();
} }
public async void OnButtonClicked(object sender, EventArgs e)
{
await Navigation.PushAsync(new NewPage1());
}
} }

@ -1,8 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Banquale.Views.NewPage1" xmlns:model="clr-namespace:Banquale.Model"
Title="NewPage1"> x:Class="Banquale.Views.NewPage1">
<ContentPage.BindingContext>
<model:Manager/>
</ContentPage.BindingContext>
<VerticalStackLayout> <VerticalStackLayout>
<Label <Label
Text="Welcome to .NET MAUI!" Text="Welcome to .NET MAUI!"
@ -13,8 +19,21 @@
Text="Click me" Text="Click me"
Clicked="Button_Clicked"/> Clicked="Button_Clicked"/>
<ListView <Button
ItemsSource="{Binding Client}" /> Clicked="ArrowBack" />
<ListView ItemsSource="{Binding ListeClients}" x:Name="ListViewID">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Label Text="{Binding Nom}" />
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</VerticalStackLayout> </VerticalStackLayout>
</ContentPage> </ContentPage>

@ -5,17 +5,28 @@ public partial class NewPage1 : ContentPage
{ {
public Manager myManager => (App.Current as App).MyManager; public Manager myManager => (App.Current as App).MyManager;
public NewPage1() public NewPage1()
{ {
InitializeComponent(); InitializeComponent();
}
ListViewID.BindingContext = myManager;
}
int cpt = 0; int cpt = 0;
void Button_Clicked(System.Object sender, System.EventArgs e) void Button_Clicked(System.Object sender, System.EventArgs e)
{ {
myManager.AjouterClient(new Client("Monsieur", "Bonjour", "HelloThisIsMyPassword")); Client client1 = new Client("Monsieur", "Bonjour", "HelloThisIsMyPassword");
myManager.AjouterClient(client1);
cpt++; cpt++;
Console.WriteLine(cpt); Console.WriteLine(cpt);
Console.WriteLine(client1.Nom);
} }
public async void ArrowBack(object sender, EventArgs e)
{
await Navigation.PopAsync();
}
} }

Loading…
Cancel
Save