0

I want to show in a ListView, that is declared in XAML, the purchases that a selected customer has made, so I thought of declaring a class where I can store data from each customer and in that class declaring an attribute to store each purchase done, but I cannot find the way to show it properly. I already have some methods to get data input from user, and it's working for my class Customer but once I try to show the Purchase ListView data doesn't appear.

I don't know how to implement the code to show data from each one of the purchases ofin the ListView that I have declared at the XAML

//Main
namespace WpfApp1 
{
    public partial class MainWindow : Window
    {
        public ObservableCollection<Customer> lc = new ObservableCollection<Customer>();
        //Code 
    }
}

//Customer.cs
public class Customer
{
    public string name {get; set; }
    public string surname {get; set;}
    public ObservableCollection<Purchase> lp;
}

//Purchase.cs
public class Purchase 
{
    public DateTime date {get; set;}
    public string shop {get; set;}
}
aya
  • 3
  • 2
  • 1
    WPF only binds to properties, not fields. You need to make `Customer.lp` a (PascalCased) property. As it's an `ObservableCollection` it should be a `get`-only property with an initializer. – Dai Nov 21 '22 at 19:00
  • Why not name them `Customers` and `Purchases` instead of `lc` and `lp`? Use meaningful names, and thank yourself later! – Mathieu Guindon Nov 21 '22 at 20:51

0 Answers0