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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:15:17+00:00 2026-05-19T09:15:17+00:00

If I want to bind something like a combobox in the code-behind I have

  • 0

If I want to bind something like a combobox in the code-behind I have no problem at all. Something like :

List<string> strings = new List<string>();
AddStringsFromDataSourceToList(strings);

comboBox1.ItemSource = strings;

As far as I can tell, there is no quick and dirty way to do this in XAML. For all of the praise wpf is receiving for its super simple databinding, something this simple seems far easier to just do in C#. Is there an easier way to do this than creating DependencyProperty wrappers and adding them as resources without much help from intellisense or all that goes into ObservableCollections? I understand that its not impossible, but I must be missing something if such a simple task seems so in depth…

EDIT: To clarify, adding dynamic Lists is the issue here, not static arrays. It is super easy to add items manually, as many have pointed out.

  • 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-19T09:15:18+00:00Added an answer on May 19, 2026 at 9:15 am

    Sure there is:

    <ComboBox>
        <ComboBoxItem>One</ComboBoxItem>
        <ComboBoxItem>Two</ComboBoxItem>
    </ComboBox>
    

    There are other syntaxes depending on your goal that are nearly as simple – using resources or inline itemssources, or grouped data.. even xml data. Don’t throw up your hands in frustration because the first thing you tried wasn’t easy – wpf is worth the learning curve, in my opinion.

    WPF gets praise because it makes separating the visuals from the behavior much easier than windows forms, and because it makes creating nice visual effects much much easier, not because it makes it easier to do trivial examples. However, in this case – it is easier to do the trivial example.

    With your edit Where do you want to pull them from? You don’t have to create dependency properties or observable collections by any means. A simple list property will do (I prefer to use a collectionviewsource in the xaml in that case). Also, don’t forget that you don’t need to use all XAML if you hate it. But if you design for WPF instead of in spite of it you’ll find a lot of tasks (like this one) easy.

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

Sidebar

Related Questions

I want to get my ComboBox in XAML to bind to my List collection
It's easy to bind something to the SelectedIndex of the ListBox, but I want
i have an input element, and i want bind both change and keypress event
I have a datasource that I want to bind to a listview that has
Here's the scenario: I have a set of buttons that I want to bind
well, I have a combobox which I have bind his selectedItem property to a
I have 2 collections I want to bind to a separate GridViewColumn in a
I want to bind my UI against a collection of XElements and their properties
If I want to bind a collection to a some form of listing control
I am using C++ on Linux. I want to dynamically bind a collection of

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.