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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:32:53+00:00 2026-05-22T19:32:53+00:00

Please can you tell me how can I bind combobox. I had combobox which

  • 0

Please can you tell me how can I bind combobox.

I had combobox which Itemsource is ObservableCollection<strings>. I wont to set Selected Combobox value to MainObject.SomeValue and vice versa.

Which is the easiest way

  • 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-22T19:32:54+00:00Added an answer on May 22, 2026 at 7:32 pm

    here’s a little example.
    I have two classes:

     public class Person
        {
            private string _name = "Test2";
            public String Name
            {
                get { return _name; }
                set { _name = value; }
            }
        }
    
        public class DataProvider
        {
            public ObservableCollection<String> Data { get; set; }
    
            public DataProvider()
            {
                Data = new ObservableCollection<string>();
                Data.Add("Test");
                Data.Add("Test2");
                Data.Add("Test3");
                Data.Add("Test4");
            }
        }
    

    The DataProvider provides the string data for the combo box and the Person is the object where you want to bind the name. This can be done as followed:

    <Grid.Resources>
                <myNamespace:DataProvider x:Key="DataProvider"/>
                <myNamespace:Person x:Key="Person"/>
            </Grid.Resources>
            <ComboBox 
                Height="25" 
                DataContext="{StaticResource DataProvider}" 
                ItemsSource="{Binding Data}" 
                SelectedItem="{Binding Name, Source={StaticResource Person}, Mode=TwoWay}"/>
    

    This is just a quick example. Have a look at SelectedItem, SelectedValue, SelectedValuePath if you don’t want to use string as input data…

    Is this what you needed?

    BR,

    TJ

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

Sidebar

Related Questions

Please tell me how can i bind a hashtable to a WPF Combobox. I
I am trying bind my application just to my VPS. Can you please tell
please can you tell me why this wont work. If I call s.A why
can please anyone can tell me to how set the row colors of the
please can anyone tell me how to validate a text box while iam moving
I need to update jquery1.3.2 to jquery1.4 (in Asp.net MVC). Please can anyone tell
Please can some one briefly tell me with example what does the means of
Can please some tell me when does the above written error occurs. I just
Can someone tell me please why the following example work in Firefox but not
Can someone please tell me what this means: 07-04 09:54:38.048: I/DetailActivity(15496): Title that is

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.