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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:46:33+00:00 2026-05-12T19:46:33+00:00

Let me first describe my goal: I have created an object with 3 properties:

  • 0

Let me first describe my goal: I have created an object with 3 properties: start, end and time. I have created an ObservableCollection of 8 of these properties, so it looks like this:

//C#
internal class MyObjects : ObservableCollection<MyObjectSetting>
        {
            public MyObjects()
                : base()
            {
                Add(new MyObjectSetting(
                            start1,
                            end1,
                            time1);
                Add(new MyObjectSetting(
                            start2,
                            end2,
                            time2);
    (etc)
            }
        }

I would like to have 3 ComboBoxes that bind to the individual properties listed in these 8 objects, so ComboBoxes would look like “start1, start2, … start8”, “end1, end2, … end8”.

The following code successfully binds the ComboBox to the objects themselves, but I am stymied as to how to access the individual properties of each of the comboboxes.

// WPF
    <Grid>
        <Grid.Resources>
            <local:MyObjects x:Key="myMyObjects"/>
        </Grid.Resources>

        <ComboBox x:Name="cbxStartPosition" 
                  Grid.Row="0" 
                  Grid.Column="3" 
                  ItemsSource="{Binding Source={StaticResource myMyObjects}}"                  
                  >
    </Grid>

Can someone help me determine how to bind the properties of the objects stored in the collection to the display value shown in the ComboBox?

I’ve tried adding a DataTemplate for the ListBoxinvestigating the MultiBinding sample on MSDN here as shown below, but receive an error below:

//WPF
        <DataTemplate x:Key="StartPositionTemplate">
            <ListBox>
                <MultiBinding Converter="{StaticResource myNameConverter}">
                    <Binding Path="FirstName"/>
                    <Binding Path="LastName"/>
                </MultiBinding>
            </ListBoxItem>
        </DataTemplate>

Error 32 A value of type ‘DataTemplate’ cannot be added to a collection or dictionary of type ‘UIElementCollection’.


This error was triggered because my was not within the XAML section. HTH people in the future. Using a DataTemplate was the way to go, per the answer below.


If DataTemplate isn’t the way to go, does someone know what would be a better way to approach this?

  • 1 1 Answer
  • 2 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-12T19:46:34+00:00Added an answer on May 12, 2026 at 7:46 pm

    If you’re just trying to display the string value of a property, you can use DisplayMemberPath:

    <ComboBox ItemsSource="{Binding Source={StaticResource myMyObjects}}" DisplayMemberPath="Start"/>
    

    For more complex scenarios, you can use a custom item template:

    <ComboBox ItemsSource="{Binding Source={StaticResource myMyObjects}}">
        <ComboBox.ItemTemplate>
            <DataTemplate>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding Start}"/>
                    <TextBlock Text="{Binding End}"/>
                </StackPanel>
            </DataTemplate>
        </ComboBox.ItemTemplate>
    </ComboBox>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Thanks for viewing my question. Let me describe the app first. I have a
Let me first describe the problem. I have this application that opens a word
To describe my dilemma, let me first start with an example problem (stolen from
I am using some of these tools for the first time. I have read
Let me describe my situation first: I have a blog website, where the blog
Let me first describe my situation. I have a list of Hex values, which
Let me describe my problem first. I have a class which holds a NSMutableDictionary
I've got a strange problem. Let me first describe my situation: Webserver01 (Webapplication, SQL,
Let me first start off, sorry for the confusing title. I didn't know how
Let me first explain what's I'm trying to do. So I have a entity

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.