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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:06:53+00:00 2026-05-25T00:06:53+00:00

I have a simple question that I assume does not have a simple solution.

  • 0

I have a simple question that I assume does not have a simple solution. I need to have a multi-column ComboBox for some grid columns in my WPF DataGrid. Is there a known best-practice to accomplish this? From what I have gathered this will require subclassing the DataGridComboBoxColumn to support a custom ComboBox.

I have found some examples of this but not supporting EF entities (I’m using Code First EF).

Any advice is greatly appreciated. Thanks

NOTE: This is all done dynamically with C#. I’m not using XAML to define columns.

Update: What I mean by multicolumn is simply that when you drop the ComboBox down I need to show two values for “Display”, even though behind the scenes of course I’m still just storing an ID.

See here:.
multicolumn-dropdown
http://www.telerik.com/ClientsFiles/188010_multicolumn-dropdown.JPG

With the exception that I need to do this as a DataGridColumn that can be dynamically created and added to a grid, rather than just the simple combo shown in the image.

Update I finally managed to find an article on CodeProject where the author has developed a control with my -exact- requirements. It is located here. Now the only problem I am trying to solve is how to allow the control to work when using Entity Framework (specifically, code first). Getting closer!

  • 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-25T00:06:55+00:00Added an answer on May 25, 2026 at 12:06 am

    I have found the solution for my particular scenario. I downloaded the custom multi-column ComboBox with the included DataGridComboBoxColumn subclass from the link in my last update above. Basically I just made this work with Entity Framework Code-First POCOs and it solved my problem. Here is what I had to do to make it work with POCOs.

    Inside of the CustDataGridComboBoxColumn there are a few overrides. You just need to slightly modify the following two overrides. I’m using reflection to change set the property since I don’t know what it will be from the control.

    The original implementation accomplished this by getting the correct Row from the DataRowView with SelectedValuePath.

    protected override object PrepareCellForEdit(FrameworkElement editingElement, RoutedEventArgs editingEventArgs)
    {
          DataGridCell cell = editingEventArgs.Source as DataGridCell;
          if (cell != null)
          {
            // Changed to support EF POCOs
            PropertyInfo info = editingElement.DataContext.GetType().GetProperty("YourPropertyName", BindingFlags.Public | BindingFlags.Instance);
            object obj = info.GetValue(editingElement.DataContext, null);
            comboBox.SelectedValue = obj;
          }
          return comboBox.SelectedItem;
    }
    
    protected override bool CommitCellEdit(FrameworkElement editingElement)
    {
        // Dynamically set the item on our POCO (the DataContext).
        PropertyInfo info = editingElement.DataContext.GetType().GetProperty(“YourPropertyName”, BindingFlags.Public | BindingFlags.Instance);
        info.SetValue(editingElement.DataContext, comboBox.SelectedValue, null);
        return true;
    }
    

    Also, if you intend on creating this custom control completely in code dynamically instead of in XAML, you will have to add a setter to the Columns property because by default it is set to read-only.

    //The property is default and Content property for CustComboBox
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    public ObservableCollection<DataGridTextColumn> Columns
    {
        get
        {
           if (this.columns == null)
           {
               this.columns = new ObservableCollection<DataGridTextColumn>();
           }
           return this.columns;
        }
        set
        {
           this.columns = value;
        }
    }
    

    Thanks for the views and answers provided. Sorry I was unable to adequately word the question to make more sense initially.

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

Sidebar

Related Questions

I am learning LINQ and have a very simple question that I think will
This is a (hopefully) really simple question - I have been told recently that
Here's a very simple question. I have an SP that inserts a row into
A simple question I'm sure, but I can't figure it out. I have some
I have a simple question. Is there a way ( using reflections I suppose
I have a simple question and wish to hear others' experiences regarding which is
I have a simple question related to one-line programming. First an example: function test(a)
I have a simple question about Java's XML API and I hope there's a
I'm new to postgreSQL and I have a simple question: I'm trying to create
I have a very simple question. I want to test whether a particular port

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.