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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:06:08+00:00 2026-05-13T15:06:08+00:00

In my application I generate CheckBoxes for each possible category (retrieved from a database)

  • 0

In my application I generate CheckBoxes for each possible category (retrieved from a database) and the user can check any number that apply. I name the checkboxes “cbCategory[ID]” where ID is the ID of that category in the database.

I then need to generate some sort of collection class (as a property of my object class) to store the categoryID and a boolean value (checked/unchecked).

My question is, what would be the best type of collection class to use, and how would I go about binding it? What would the XAML and Code behind for the binding look like?

Hope this explains it well enough, thanks in advance for answers!

  • 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-13T15:06:09+00:00Added an answer on May 13, 2026 at 3:06 pm
    1. Define a class to hold the category name (string) and its checked status (bool).
    2. Define a collection of type ObservableCollection<T> where T is the class you just defined in (1).
    3. Create an ItemsControl in XAML and bind its ItemsSource property to the collection from (2).
    4. Define a DataTemplate in XAML in which you display a CheckBox and a TextBlock, bind them to the appropriate properties in your object from (1).
    5. Don’t forget to set your ItemsControl.ItemTemplate to the DataTemplate from (4).

    Using this way, you don’t need to generate controls from code, what you do need to generate is one object per category (the object defined in (1)).

    And as a side note to consider – Whenever you are generating controls manually from code – you’re doing it wrong, and there’s an easier way using binding, styling and templating (and sometimes more advanced features such as attached properties, etc.)

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

Sidebar

Ask A Question

Stats

  • Questions 431k
  • Answers 431k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You're looking for .blur() $("input.default-value").focus(function() { $(this).css("color", active_color); }).blur(function() {… May 15, 2026 at 2:14 pm
  • Editorial Team
    Editorial Team added an answer LGPL allows you to link to the code without releasing… May 15, 2026 at 2:14 pm
  • Editorial Team
    Editorial Team added an answer If you're looking for a non-JS solution, then the body… May 15, 2026 at 2:14 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.