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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:13:55+00:00 2026-05-28T04:13:55+00:00

I have a situation where ItemsSource property of a DataGrid is an array of

  • 0

I have a situation where ItemsSource property of a DataGrid is an array of integers. These integers are the keys to a corresponding dictionary. What I need to display in columns are the fields, that are members of the dictionary values objects.

<DataGrid ItemsSource="{Binding Path=thisDataContext, ElementName=control, Mode=OneWay}" 
          AutoGenerateColumns="False">                                                
    <DataGrid.Columns>
        <DataGridTextColumn Header="Name" Width="0.3*" Binding="{Binding Converter={StaticResource IntToPersonConverter}, Mode=OneWay }"  />
        <DataGridTextColumn Header="Department" Width="0.3*" Binding="{Binding Path=DepartmentIDX, Converter={StaticResource DepartmentConverter}, Mode=OneWay }" />
        <DataGridTextColumn Header="Position" Width="0.3*" Binding="{Binding Path=EmployeeTypeIDX, Converter={StaticResource EmployeeTypeConverter}, Mode=OneWay }" />
    </DataGrid.Columns>     
</DataGrid>

The object of a class Person I’m working with have Properties – Department and Position ids, so I’ve implemented multiple Converters – Person to Department name and Person to Postition name. I have no idea how to combine all of them. I thought that would be possible if I could set DataContext properties to the DataGrid Rows. So I could pass a Person object to a Convertor.

  • 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-28T04:13:56+00:00Added an answer on May 28, 2026 at 4:13 am

    There’s no much point in exercising WPF futures such as binding converters etc just for the sake of proving that they work – they do. The number of calls to converter is going to be massive, which isn’t elegant at least and is easily avoidable. I’d suggest that you pre-process your collection before setting grid’s ItemsSource.

    I would personally use LINQ projectsions, and establish the dictionaries as static members of your class. Give us a shout and I’ll post a sample.

    Update 1 – Sample Code

    public class Person
        {
            private static Dictionary<int, string> Departments;
    
            static Person()
            {
                Person.SetUpDictionaries();
            }
    
            private static void SetUpDictionaries()
            {
                Person.Departments = new Dictionary<int, string>(3)
                {
                    { 1, "IT" },
                    { 1, "Finance" },
                    { 1, "HR" }
                };
            }
    
            public int DepartmentId
            {
                get;
                set;
            }
    
            public string Depratment
            {
                get { return Person.Departments[this.DepartmentId]; }
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have situation where I need to change the order of the columns/adding new
I have situation where I need to make sure that user has completed certain
I have created a WPF tooklit datagrid in C# and the ItemsSource is set
I have a situation where I need to access an object that has been
I have situation where I am mapping table's columns to the primary key of
I have a situation where I need to style the selected item in a
Situation: Have a UITextField instance which is a subview of a UIScrollView. Need: Screen
I have a situation where i need to set SelectedIndex of my combobox to
Situation: I've created a DataGrid in XAML and the ItemsSource is binded to an
I have situation when I need to communicate with Java process somehow. Java handling

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.