Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8915995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:07:17+00:00 2026-06-15T05:07:17+00:00

I start now to work with wpf (Coming from Windows Forms) and I want

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:07:18+00:00Added an answer on June 15, 2026 at 5:07 am

    A simple way is to use a nested ItemsCollection:

    <ItemsControl ItemsSource="{Binding ListOfBanks}">
        <ItemsControl.ItemTemplate>
            <DataTemplate>
            <StackPanel>
                <TextBlock Text="{Binding ListOfAccounts.Count,StringFormat='Number of Accounts: {0}'}" />
                <ItemsControl ItemsSource="{Binding ListOfAccounts}">
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="{Binding Description}" />
                            <TextBlock Grid.Column="1" Text="{Binding Money,StringFormat='{}{0:C}'}" />
                        </Grid>
                    </DataTemplate>
                </ItemsControl>
            </StackPanel>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
    

    ItemsControl is a basic repeating control — if you want bells and whistles use ListBox (item selection) or DataGrid (sorting, grouping, automatic columns, etc).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to start work on phone gap. Till now i have found out
I'll start by quoting google's blog Project owners can now create multiple repositories for
I'm using System.Timers.Timer in my WPF application. I want to understand how Timer does
I use Delphi 2007 in my daily work and have now start to look
I put my home directory under version control. If I now start git-gui from
I'm hosting a WPF UserControl in a WinForms container. Now, I want to be
In fact, -static gcc flag on Linux doesn't work now. Let me cite from
When I start emacs now, prelude is no longer activated. This is my personal.el
I am setting up the development environment for my start-up just now. I use
I'm now with the dream to start a project of a emulator of old

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.