fix data binding issue

pull/42/head
Antoine PEREDERII 2 years ago
parent 85c2f2e5ad
commit c19df0275e

@ -15,12 +15,13 @@ public partial class App : Application
MyManager.DataLoad();
MyManager.Persistence = new DataContractPersistance.DataContractPers();
MyManager.DataSave();
InitializeComponent();
MainPage = new AppShell();
//MyManager.DataSave();
}
}
}

@ -3,11 +3,13 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace Banquale.Model
{
[DataContract]
public class Account : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
@ -17,9 +19,10 @@ namespace Banquale.Model
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
[DataMember]
public double Balance
{
get => Balance;
get => balance;
set
{
if (balance == value)
@ -30,8 +33,8 @@ namespace Banquale.Model
}
private double balance;
[DataMember]
public string Name
{
get => name;
@ -45,6 +48,8 @@ namespace Banquale.Model
}
private string name;
[DataMember]
public string IBAN
{
get => iban;
@ -66,7 +71,8 @@ namespace Banquale.Model
IBAN = iban;
}
public List<Transactions> TransactionsList { get; set; }
[DataMember]
public List<Transactions> TransactionsList { get; set; } = new List<Transactions>();
//public bool DoTransactions(string name, string IBAN, float sum)
//{
@ -97,7 +103,7 @@ namespace Banquale.Model
internal static void AskForHelp(Entry request, Entry subject, Editor message)
{
Debug.WriteLine(request);
Debug.WriteLine(request.Text);
Debug.WriteLine(subject);
Debug.WriteLine(message);
Debug.WriteLine("Help button pressed !");

@ -12,7 +12,7 @@ namespace Banquale.Model
public class Customer : Person
{
[DataMember]
public List<Account> AccountsList { get; private set; }
public List<Account> AccountsList { get; private set; } = new List<Account>();
//private uint NbAccounts { get; set; } = AccountsList.Count;

@ -1,7 +1,9 @@
using System.ComponentModel;
using System.Runtime.Serialization;
namespace Banquale.Model
{
[DataContract]
public class Transactions : INotifyPropertyChanged
{
@ -9,7 +11,9 @@ namespace Banquale.Model
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public int Type
[DataMember]
public int Type
{
get => type;
set
@ -20,9 +24,11 @@ namespace Banquale.Model
OnPropertyChanged(nameof(Type));
}
}
[DataMember]
private int type;
[DataMember]
public Double Sum
{
get => sum;
@ -34,8 +40,10 @@ namespace Banquale.Model
OnPropertyChanged(nameof(Sum));
}
}
[DataMember]
private Double sum;
[DataMember]
public Account InvolvedAccounts
{
get => involvedAccounts;
@ -47,8 +55,10 @@ namespace Banquale.Model
OnPropertyChanged(nameof(InvolvedAccounts));
}
}
[DataMember]
private Account involvedAccounts;
[DataMember]
public string Category
{
get => category;
@ -60,8 +70,10 @@ namespace Banquale.Model
OnPropertyChanged(nameof(Category));
}
}
[DataMember]
private string category;
[DataMember]
public DateTime Date
{
get => date;
@ -73,6 +85,7 @@ namespace Banquale.Model
OnPropertyChanged(nameof(Date));
}
}
[DataMember]
private DateTime date;
public Transactions(int type, Double sum, Account involvedAccounts, string category, DateTime date)

@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using Banquale.Model;
namespace Banquale.Stub
@ -21,13 +22,24 @@ namespace Banquale.Stub
Transactions Transactions2 = new Transactions(1, 54.99, Account2, "Test", new DateTime(2022, 8, 15));
Transactions Transactions3 = new Transactions(0, 1000, Account3, "Test", new DateTime(2020, 9, 1));
Console.WriteLine(Customer1);
Debug.WriteLine(Customer1.Name, Customer1.Password);
List<Customer> CustomersList = new List<Customer>();
List<Transactions> TransactionsList= new List<Transactions>();
List<Account> AcountsList = new List<Account>();
AcountsList.Add(Account1);
AcountsList.Add(Account2);
AcountsList.Add(Account3);
List<Account> AccountsList = new List<Account>();
Account1.TransactionsList.Add(Transactions1);
Account2.TransactionsList.Add(Transactions2);
//AccountsList.Add(Account1);
//AccountsList.Add(Account2);
//AccountsList.Add(Account3);
Customer1.AccountsList.Add(Account1);
Customer1.AccountsList.Add(Account2);
CustomersList.Add(Customer1);
CustomersList.Add(Customer2);

@ -42,7 +42,7 @@
TextColor="Black"
HorizontalOptions="Center"/>
<Label
Text="{Binding AccountList[0].Balance}"
Text="{Binding CustomersList[0].AccountList[0].Balance}"
Grid.Column="1"
MinimumWidthRequest="70"
TextColor="Black"

Loading…
Cancel
Save