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

The Archive Base Latest Questions

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

Apologies in advance as i’m aware this question has appeared several times. However, i’m

  • 0

Apologies in advance as i’m aware this question has appeared several times. However, i’m struggling to identify where i’m going wrong with my own code. Just looking for a list of checkboxes and names next to them. Currently it compiles ok but the ListBox is empty.

All of the code is within a control called ucDatabases.

XAML:

<ListBox Grid.Row="4" ItemsSource="{Binding Databases}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <CheckBox Content="{Binding Name}" IsChecked="{Binding IsChecked}" Margin="5 5 0 0"/>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

C# Code:

  public ObservableCollection<CheckBoxDatabase> Databases;

public class CheckBoxDatabase : INotifyPropertyChanged
        {
            private string name;
            private bool isChecked;
            public Database Database;

            public bool IsChecked
            {
                get { return isChecked; }
                set
                {
                    isChecked = value;
                    NotifyPropertyChanged("IsChecked");
                }
            }

            public string Name
            {
                get { return name; }
                set
                {
                    name = value;
                    NotifyPropertyChanged("Name");
                }
            }

            public event PropertyChangedEventHandler PropertyChanged;
            protected void NotifyPropertyChanged(string strPropertyName)
            {
                if (PropertyChanged != null)
                    PropertyChanged(this, new PropertyChangedEventArgs(strPropertyName));
            }
        }

Helper method to populate some test data:

private void SetTestData()
    {
        const string dbAlias = "Database ";
        Databases = new ObservableCollection<CheckBoxDatabase>();
        for (int i = 0; i <= 4; i++)
        {
            var db = new Database(string.Format(dbAlias + "{0}", i));
            var newCBDB = new CheckBoxDatabase {Database = db, IsChecked = false, Name = db.Name};

            Databases.Add(newCBDB);
        }
    }

Advice and a solution would be much appreciated!

  • 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-18T05:17:03+00:00Added an answer on June 18, 2026 at 5:17 am

    public ObservableCollection<CheckBoxDatabase> Databases; is a field.

    You should replace it with a Property:

    public ObservableCollection<CheckBoxDatabase> Databases {get;set;};

    Don’t forget INotifyPropertyChanged!

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

Sidebar

Related Questions

My apologies in advance if this question has already been answered. I have been
All, Apologies in advance - this question might be too open-ended for SO. Anyway...
This may be a bit of an abstract question, so apologies in advance. I
This, I'm sure is a pretty basic question about JavaScript, so apologies in advance.
Apologies in advance for the rudimentary nature of this CSS question. I'm trying to
Apologies in advance, this is a long question. (TL;DR : Does anyone have any
Apologies in advance because I'm really unsure how to ask this question so if
Apologies in advance for the length of this question! I have a data structure
Apologies in advance if this question is badly worded! I have a MySQL table
(Apologies in advance if this question is short on details, I'll watch the comments

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.