Continue DataBinding
continuous-integration/drone/push Build is failing Details

DataBinding
Matheo HERSAN 2 years ago
parent f5f5c1fc86
commit 6e88c66e20

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MangaMap.DataBinding
{
public interface INotifyPropertyChanged
{
public event PropertyChangedEventHandler? PropertyChanged;
}
}

@ -1,18 +1,37 @@
namespace MangaMap.Views;
using Model;
using System.ComponentModel;
public partial class ficheAnime : ContentPage
public partial class ficheAnime : ContentPage, INotifyPropertyChanged
{
public Oeuvre AnimeModel { get; set; }
private Oeuvre animeModel;
public Oeuvre AnimeModel
{
get { return animeModel; }
set
{
if (animeModel != value)
{
animeModel = value;
OnPropertyChanged(nameof(AnimeModel));
}
}
}
public ficheAnime()
{
InitializeComponent();
// Exemple de création d'une instance de la classe Oeuvre
List<string> genres = new List<string>() { "Action", "Aventure" };
AnimeModel = new Oeuvre("Nom de l'oeuvre", genres, "Type de l'oeuvre", "Description de l'oeuvre", 5, 12, "Chemin/vers/l'affiche.png");
AnimeModel = new Oeuvre("Evangelion", genres, "Type de l'oeuvre", "Description de l'oeuvre", 5, 12, "Chemin/vers/l'affiche.png");
InitializeComponent();
this.BindingContext = this;
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}

@ -12,14 +12,15 @@
<VerticalStackLayout Grid.Row="1">
<HorizontalStackLayout>
<Rectangle
WidthRequest="150"
HeightRequest="150"
Fill="Red"
HorizontalOptions="Start"
Margin="50"/>
<Label Text="Titre" FontSize="Header" VerticalOptions="Center"/>
<ImageButton
Style="{StaticResource ImageAnime}"
BackgroundColor="Orange"
Margin="50"
Source="test.jpg"
/>
<Label Text="{Binding AnimeModel.Nom}" FontSize="Header" VerticalOptions="Center" TextColor="{StaticResource Primary}"/>
</HorizontalStackLayout>
<Grid>
@ -46,7 +47,7 @@
Text="Je suis une description. Je suis une description. Je suis une description. Je suis une description. Je suis une description. Je suis une description. Je suis une description. Je suis une description. Je suis une description. Je suis une description."
Margin="20"/>
<Label Text="{Binding AnimeModel.Nom}" FontSize="Header" VerticalOptions="Center" TextColor="{StaticResource Primary}"/>
<Label Text="{Binding AnimeModel.Description}" Margin="20" TextColor="Wheat"/>
<Entry Text="{Binding AnimeModel.Nom}" Placeholder="Entrez le nom"/>

Loading…
Cancel
Save