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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:10:09+00:00 2026-05-24T19:10:09+00:00

This is the user control which I’m working on. The items in the first

  • 0

This is the user control which I’m working on. The items in the first comboBox are gonna be the same in dataGridColumn GroupID.

enter image description here

The code to show in the first comboBox is

    <ComboBox ItemsSource="{Binding}" Name="GroupComboBox" SelectedValuePath="GroupID" DisplayMemberPath="GroupName" Grid.Column="1" Margin="5" />

    private void LoadGroups()
    {
        NorthwindDataContext dc = new NorthwindDataContext();

        var groups = (from p in dc.Group
                      select p);

        this.DataContext = groups;
    }

    private void LoadStudents()
    {
        NorthwindDataContext dc = new NorthwindDataContext();

        var students = (from p in dc.Student
                         select p);

        dataGrid1.ItemsSource = students;
    }

But in the another comboBox, don’t appear any item in it.

            <DataGridTemplateColumn Header="GroupID">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <ComboBox ItemsSource="{Binding}" SelectedValuePath="GroupID" DisplayMemberPath="GroupName" />
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>

How can I bind it?

I was thinking in put all the Groups in a list, but I’m not sure it’ll be a good way because I’d need to convert my query in a list.

UPDATE 1:

I had to remove this line:

            <DataGridComboBoxColumn Header="GroupID" ItemsSource="{Binding DataContext, RelativeSource={RelativeSource AncestorType=UserControl}}" SelectedValuePath="GroupID" DisplayMemberPath="GroupName" />

for

            <DataGridTemplateColumn Header="GroupID">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <ComboBox ItemsSource="{Binding DataContext, RelativeSource={RelativeSource AncestorType=UserControl}}" SelectedValuePath="GroupID" DisplayMemberPath="GroupName" SelectedValue="{Binding GroupID}" />
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
  • 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-24T19:10:09+00:00Added an answer on May 24, 2026 at 7:10 pm

    The binding of your internal ComboBox will not work because the DataContext of that ComboBox is your Groups collection but one of the Students, this means setting the ItemsSource to {Binding} will make the Student the ItemsSource.

    You can navigate up the Tree with a RelativeSource binding to a place where the inherited DataContext is still the Groups collection, e.g. if the inheritance is not blocked by setting the DataContext inbetween this will work:

    {Binding DataContext, RelativeSource={RelativeSource AncestorType=DataGrid}}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've built a custom user control which inherits ComboBox and has items which are
I have a user control which has a textbox on it, now this usercontrol
I have a user control which I use as a listboxItem. On this user
I have a user control which contains the following code: <form id=CurrencyForm method=post runat=server>
I have a user control...and the base page(s) which uses this user control has
I have a user control which has several radiobuttons and buttons... I have code
I have a user control which shows list of latest announcements. This user control
I have a Windows form which hosts a custom User Control. This User Control
I have a user control which has a number of properties. This user control
I've got this user control which is producing a 1px border around the ListBox.

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.