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 3426638
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:44:23+00:00 2026-05-18T06:44:23+00:00

You may read the complete structure of my solution here , but here’s the

  • 0

You may read the complete structure of my solution here, but here’s the quick reference:

  1. I made a class Account.cs in the Entities class library.
  2. I made a class library Core with a class AccountController.cs which gets the
    accounts from the Sql Server tables.
  3. I made a class AccountWindowController.cs in the Gui.Wpf.Controllers class library.
    It contains the List<Account> Accounts property and calls for the GetAccounts()
    method in the AccountController to fill that list.
  4. Finally, I made a AccountWindow.xaml in the Gui.Wpf class library. This WPF window
    contains a ListBox named AccountsListBox.

I want to data bind the list box from AccountWindow to the list in the AccountWindowController, but I don’t know how. Here’s the relevant code:

AccountWindow.xaml

<Window x:Class="Gui.Wpf.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controller="clr-namespace:Gui.Wpf.Controllers"
    Title="Accounts" 
    Width="350" 
    MinWidth="307" 
    MaxWidth="400" 
    Height="500" >

    <Window.Resources>
        <controller:AccountWindowController
            x:Key="AccountsCollection" />
    </Window.Resources>

    <Grid>
        <ListBox 
            Name="AccountsListBox" 
            Margin="12,38,12,41" 
            ItemsSource="{StaticResource ResourceKey=AccountsCollection}" />
    </Grid>

</Window>

AccountWindow.xaml.cs

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        new Gui.Wpf.Controllers.AccountWindowController();
    }
}

AccountWindowController.cs

public class AccountWindowController
{
    //This event is handled in the AccountController.cs 
    //that sets the Accounts property defined below.
    public event EventHandler GetAccounts;

    private List<Account> accounts;
    public List<Account> Accounts
    {
        get
        {
            GetAccounts(this, new EventArgs());
            return accounts;
        }
        set
        {
            this.accounts = value;
        }
    }

    //Constructor
    public AccountWindowController()
    {
        new AccountController(this);
    }
}

Thank you for all the help.

  • 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-18T06:44:24+00:00Added an answer on May 18, 2026 at 6:44 am

    The ItemsSource needs to be an IEnumerable. The AccountsCollection resource is a class that contains the property you want to use. In order to do this, you need to bind to that property, and use the resource as the source of the binding:

    <ListBox Name="AccountsListBox"
             Margin="12,38,12,41" 
             ItemsSource="{Binding Accounts, Source={StaticResource ResourceKey=AccountsCollection}}" />
    

    You should also implement INotifyPropertyChanged on the AccountWindowController
    (and raise PropertyChanged in the Accounts setter) so that if you set the Accounts property, the ListBox will rebind to the new collection. And if the Accounts collection is modified at runtime, it should be an ObservableCollection.

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

Sidebar

Related Questions

I have read several questions regarding this but I fear they may be out
This may be a case of me just misunderstanding what I've read, but all
I read through the comments here: Is this a reasonable user registration process? but
I finally got my code to reference the ruby-alsa library , but I'm stuck
I have read in C++ : The Complete Reference book the following Even though
Before someone said that I did not read I may say that I read
I read that spammers may be downloading a specific registration page on my site
My program has to read files that use various encodings. They may be ANSI,
I'm trying to read in a file with names and addreses. It may look
May be I am getting old, but I can't find it...

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.