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

  • Home
  • SEARCH
  • 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 6669657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:10:35+00:00 2026-05-26T03:10:35+00:00

I am trying to create a WPF application where I have a StackPanel that

  • 0

I am trying to create a WPF application where I have a StackPanel that shows a list of accounts. There is an Account object in the code behind for each account, stored in a List structure. I want to databind this to my WPF, but I don’t want a listbox.

Instead, I defined a template for how each account summary should appear. I then want to stack these in a StackPanel and call it a day.

The problem is that the Data Binding only takes the first item from the list and that’s it. How to I bind it so that this effectively creates a little stacked list of nicely formatted chunks of data?

Here is the relevant WPF code:

<StackPanel Name="sp_AccountList" Margin="0,0,0,0" VerticalAlignment="Top">
    <StackPanel.Resources>
    <svc:AccountBalanceColorConverter x:Key="accountColorConverter" />
    <Style x:Key="AccountSummaryBackgroundGradient" TargetType="{x:Type StackPanel}">
    <!-- nice formatting code here -->
    </Style>
    <Style x:Key="AccountSummaryNameStyle" TargetType="{x:Type TextBlock}">
        <Setter Property="Padding" Value="10,0,0,0" />
        <Setter Property="FontSize" Value="18" />
        <Setter Property="Height" Value="20" />
        <Setter Property="FontFamily" Value="Cambria" />
        <Setter Property="Foreground" Value="White" />
        <Setter Property="Background" Value="Transparent" />
    </Style>
    <Style x:Key="AccountSummaryBalanceStyle" TargetType="{x:Type TextBlock}">
        <Setter Property="Padding" Value="10,0,0,0" />
        <Setter Property="FontSize" Value="14" />
        <Setter Property="Height" Value="20" />
        <Setter Property="FontFamily" Value="Cambria" />
        <Setter Property="Background" Value="Transparent" />
    </Style>                    
    <ObjectDataProvider x:Key="accounts"
                        ObjectType="{x:Type svc:AccountService}"
                        MethodName="ListAccounts" />
    <DataTemplate x:Key="AccountSummaryLayout">
    <StackPanel Orientation="Vertical" Style="{StaticResource AccountSummaryBackgroundGradient}">
        <TextBlock Text="{Binding Path=Name}" Style="{StaticResource AccountSummaryNameStyle}" />
        <StackPanel Orientation="Horizontal">
            <TextBlock Foreground="{Binding Path=TotalAccountBalance, Converter={StaticResource accountColorConverter} }" Text="{Binding Path=TotalAccountBalance, Mode=OneWay}" Style="{StaticResource AccountSummaryBalanceStyle}" />
            <TextBlock Foreground="{Binding Path=AvailableAccountBalance, Converter={StaticResource accountColorConverter} }" Text="{Binding Path=AvailableAccountBalance, Mode=OneWay}" Style="{StaticResource AccountSummaryBalanceStyle}" />
        </StackPanel>
    </StackPanel>
    </DataTemplate>
    </StackPanel.Resources>
    <StackPanel Orientation="Vertical">
        <ContentPresenter x:Name="AccountSummaryPresenter" ContentTemplate="{StaticResource AccountSummaryLayout}" Content="{DynamicResource accounts}" />
    </StackPanel>
</StackPanel>
  • 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-05-26T03:10:36+00:00Added an answer on May 26, 2026 at 3:10 am

    StackPanel does not have an ItemsSource property, its children controls are not databindable.

    What you can do is create an ItemsControl which uses a StackPanel as its Itemshost.

         <ScrollViewer>
                <ItemsControl ItemsSource="{Binding Source={StaticResource accounts}}">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel IsItemsHost="True" Orientation="Vertical" />
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemTemplate>
                    ...
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            <ScrollViewer>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a WPF application that takes command line arguments. If
I have a problem with my WPF program. I'm trying to create an object
I am trying to create a popup from my WPF application which shows a
I am trying to create a user control within a WPF application that will
I'm trying to create a WPF application where I can drag an image around.
I'm trying to create a WPF Shape (PolyLine) editor, which is a control that
I am trying create a WCF service that leverages the WPF MediaPlayer on the
Trying to create a user account in a test. But getting a Object reference
I'm trying to create an application that adheres to the following: No Taskbar No
I am trying to create a databound WPF GridView whose rows can either be

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.