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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:01:27+00:00 2026-05-17T00:01:27+00:00

I am DataTemplating a listbox’s itemsource to display a label and combobox. In the,

  • 0

I am DataTemplating a listbox’s itemsource to display a label and combobox. In the, datatemplate I am assigning a new itemssource to the combobox but cant get it to work.

Or Ideally, how can I bind the combobox in a datatemplate to a different source.

Thanks. Mani

UserControl:

<DockPanel>
        <ListBox x:Name="lstBox" ItemsSource="{Binding FilterControls}" />
</DockPanel>

 <!--DataTemplate For SearchElement Type-->
<DataTemplate DataType="{x:Type CustomTypes:FilterElement}">
  <Label> Text </Label>
  *<ComboBox  ItemsSource="{Binding Employees}"DisplayMemberPath="Sex" />*
</DataTemplate>

ViewModel:

List<FilterElement> FilterControls;
List<Employee> Employees

Class FilterElement 
{
string Caption;
}

class Employee
{
string Sex;
}

  • 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-17T00:01:27+00:00Added an answer on May 17, 2026 at 12:01 am

    In your combobox, you are binding to Employees in the current data context, which would be a FilterElement object – no Employees property to bind to.

    In your binding, you probably want to set Source= to something else, which overrides your datacontext

    There are lots of ways to set this one easy way to do this (easy to put here, anyway) would be to add a collectionViewSource to the resources of your window/control (I put Whatever.Resources – it can go in nearly any containing element)

    <Whatever.Resources>
      <CollectionViewSource x:Key="employeeSource" Source="{Binding Employees}">
    </Whatever.Resources>
    

    Then in your datatemplate

    <ComboBox ItemsSource={Binding Source={StaticResource employeeSource}}" ... />
    

    Note that using a CollectionViewSource will allow you to do sort/group in xaml as well.

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

Sidebar

Related Questions

I am DataTemplating a listbox's ItemSource to display a series of comboboxes. I want
I have two classes A & B, and a listbox. I assign listBox.ItemsSource equal
I bound a datatable to a combobox and defined a dataTemplate in the itemTemplate.i
So how do you display complex aggregated ViewModels whose Models have relations to each
Trying to get my head around MVVM, and getting a simple window to render
I have having issues with a storyboard that is complaining about being unfreezable. There
I'm needed to create a list box as in below format; [x] [x] ^
I'm writing an app that connects to network resources. When the app is connecting,

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.