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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:19:43+00:00 2026-05-25T11:19:43+00:00

I would like an array of 10 combo boxes on a wpf form. The

  • 0

I would like an array of 10 combo boxes on a wpf form.

The ItemsSource of the combo boxes are identical – an ObservableCollection of selectable Items.

Each Selected Item will bound to an item in a different ObservableCollection, imaginatively called ‘SelectedItems’..

What is the best way to do the array? I could of course have 10 separate combo boxes but this would be not very elegant..

I don’t think an ItemsControl template is what I’m after as the number of combo boxes is static.

Thanks

Joe

  • 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-25T11:19:43+00:00Added an answer on May 25, 2026 at 11:19 am

    If I understand you right, you have 10 ComboBoxes with the same item list, but different data sources

    In that case, I could create a common style for the ComboBox which sets the common properties such as ItemsSource (and SelectedItem if the binding is the same for all items), and then actually create the individual ComboBoxes on the form as needed.

    <StackPanel>
        <StackPanel.Resources>
            <Style TargetType="{x:Type ComboBox}">
                <!-- Set the binding to wherever your ItemsSource resides. In this
                     case,I'm binding to a static class called Lists and a static 
                     property called ComboBoxItems -->
                <Setter Property="ItemsSource" 
                        Value="{Binding Source={x:Static local:Lists.ComboBoxItems}}" />
    
                <!-- Only use this setter if your binding is the same everywhere -->
                <Setter Property="SelectedItem" Value="{Binding SelectedItem}" />
            </Style>
        </StackPanel.Resources>
    
        <ComboBox DataContext="{Binding Item1}" />
        <ComboBox DataContext="{Binding Item2}" />
        <ComboBox DataContext="{Binding Item3}" />
        <ComboBox DataContext="{Binding Item4}" />
        <ComboBox DataContext="{Binding Item5}" />
        <ComboBox DataContext="{Binding Item6}" />
        <ComboBox DataContext="{Binding Item7}" />
        <ComboBox DataContext="{Binding Item8}" />
        <ComboBox DataContext="{Binding Item9}" />
        <ComboBox DataContext="{Binding Item10}" />
    </StackPanel>
    

    Of course, if the DataSource for your ComboBoxes CAN be put in a collection, it is preferred that they are and that you use an ItemsControl to display the ComboBoxes

    <ItemsControl ItemsSource="{Binding SelectedItems}">
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <ComboBox SelectedItem="{Binding }"
                          ItemsSource="{Binding Source={x:Static local:Lists.ComboBoxItems}}" />
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to filter an array of items by using the map() function.
I would like to append html to an item in my array before echoing
with the hash below, I would like the clients array's reference : my $this
I would like to sort an array in ascending order using C/C++ . The
I would like to initialize an array of structs, with the same element repetitively,
I would like to sort an array of strings in a directory, given a
I would like to copy an array of pixel data (colors) into a texture.
I would like to print an array to a file. I would like the
I would like to return an array of string in my web services I've
I would like to know how to output an array of doubles to the

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.