I start now to work with wpf (Coming from Windows Forms) and I want now to create a little tool for playing around with wpf.
I understand that there are Bindings and templates, and understand what they do, and know that I have to fill the Window.DataContext and can the bind to this but for my example I don’t get it all together, maybe someone can help me, to understand this better.
Models are
class ViewModel
{
public List'Bank ListOfBanks { get; set; }
}
class Bank
{
public List'Account ListOfAccounts { get; set; }
}
class Account
{
public String Description { get; set; }
public Decimal Money { get; set; }
}
What I want to do, is to have a dynamic list of (some nice blue) rectangles (Count = Number of Banks in ListOfBanks property) and in this Rectangle should be a grid with two columns (Description and Money properties) which should have as much as rows like there are Accounts in the ListOfAccounts property from the bank model.
What I know is
public MainWindow()
{
InitializeComponent();
this.DataContext = new ViewModel();
}
I know this is not much. And I know how to bind the grid columns against the Account properties, thats all.
It would be great if someone can help me with this.
Kind regards
A simple way is to use a nested
ItemsCollection:ItemsControl is a basic repeating control — if you want bells and whistles use
ListBox(item selection) orDataGrid(sorting, grouping, automatic columns, etc).