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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:20:49+00:00 2026-05-20T21:20:49+00:00

I am aware that this topic has come up a few times before, but

  • 0

I am aware that this topic has come up a few times before, but I have tried the ways that I found here and none seem to work. I don’t know if it’s because I am using different binding sources, or if I’m just failing, or what…

I have a DataGrid which is bound to an XML document read into memory. I have a List containing all of the distinct values that one column could be and want to use this as the ItemsSource for the ComboBox column.

My XAML is as follows:

<DataGrid AutoGenerateColumns="False" IsReadOnly="False"  Height="400" HorizontalAlignment="Left" Margin="125,15,0,0" x:Name="dg" VerticalAlignment="Top" Width="500">
    <DataGrid.Columns>
        <DataGridTextColumn Header="Name" Width="40*" Binding="{Binding Path=Element[name].Value}" />
        <DataGridTextColumn Header="Count" Width="10*" Binding="{Binding Path=Attribute[count].Value}" />

<!-- I want this to be a ComboBox in a DataGridTemplateColumn -->
        <DataGridTextColumn Header="Category" Width="25*" Binding="{Binding Path=Attribute[category].Value}" /> 

        <DataGridTextColumn Header="Image Path" Width="25*" Binding="{Binding Path=Element[image].Value}" />
    </DataGrid.Columns>
</DataGrid>

And a sample XML node which si displayed would look like this:

<entry count="1" category="someCategory">
    <name>Entry 1</name>
    <image>c:\image.png</image>
</entry>

Finally, the list which I want to use as the ItemsSource for the ComboBoxes:

var categories = from category in xmlDoc.Root.Elements("entry") select category .Attribute("category").Value;
List<string> catList= categories .ToList<string>();

So when a user edits the category field I want them to have a dropdown containing the possible values contained in the list.


EDIT: Finally got this working, I did as stated in the accepted answer, set the ItemsSource of the ComboBox to

ItemsSource="{DynamicResource categoryList}"

and then simply did this in the code after creating the list item I wanted to use to populate the ComboBoxes:

Resources["categoryList"] = catList;
  • 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-20T21:20:49+00:00Added an answer on May 20, 2026 at 9:20 pm

    you have to build a DataGridTemplateColumn with a CellTemplate and a CellEditingTemplate. the following should give your the right direction to start

    <DataGridTemplateColumn Header="Category" Width="100">
      <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
          <TextBlock Text="{Binding YourProperty}" />
        </DataTemplate>
      </DataGridTemplateColumn.CellTemplate>
      <DataGridTemplateColumn.CellEditingTemplate>
        <DataTemplate>
          <ComboBox ItemsSource="{Binding YourSource, Mode=OneTime or OneWay}">
          </ComboBox>
        </DataTemplate>
       </DataGridTemplateColumn.CellEditingTemplate>          
     </DataGridTemplateColumn>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am aware that this topic has been covered already in many places, but
I'm aware that MD5 has had some collisions but this is more of a
I am aware that a thousand and one questions relating to this topic have
I aware that this will be a less programming question, but still... How can
I'm aware that there are a LOT of posts on this topic, however no
I understand that this is an insanely broad topic, but can anyone give me
I'm aware of other posts on this topic but I'm only really one rung
I am aware that there are probably other questions regarding this topic. I guess
I am aware that this is somewhat a re-post, but I feel like re-posting
I'm aware that you can do this: public ActionResult DoSomething([Bind(Exclude = CreationDate)] Item item)

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.