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

  • Home
  • SEARCH
  • 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 7965655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:13:09+00:00 2026-06-04T06:13:09+00:00

I’m currently tasked with building a spreadsheet-like GUI for a WPF application and I’ve

  • 0

I’m currently tasked with building a spreadsheet-like GUI for a WPF application and I’ve run into some issues. Essentially, I want to bind to a datagrid on a column basis so that one column contains data for a certain year. So given that 2006 is the start year and 2009 the end year, I would like to have 4 columns each displaying values for a given year on a column basis.

This is what I have in the code-behind right now:

private Years m_YearsList;

    public Years YearsList
    {
        get { return m_YearsList; }
        set { m_YearsList = value; }
    }

    public MainWindow()
    {
        InitializeComponent();

        YearsList = LoadData();

        TestGrid.DataContext = YearsList;
    }

    public Years LoadData()
    {
        var personer = new Years{
            new Year
                {
                    Taxed = new Taxed {TaxedField = 10},
                    NumBuildings = new BuildingsCollection {NumBuildings = 25},
                    Area = new Area{AreaField = "NoWhere"},
                    DisplayName = "Person1"
                },
            new Year
                {
                    Taxed = new Taxed{TaxedField = 2},
                    NumBuildings = new BuildingsCollection{NumBuildings = 8},
                    Area = new Area{AreaField = "SomeWhere"},
                    DisplayName = "Person2"
                },
                new Year
                {
                    Taxed = new Taxed{TaxedField = 18},
                    NumBuildings = new BuildingsCollection{NumBuildings = 20},
                    Area = new Area{AreaField = "UpThere"},
                    DisplayName = "Person3"
                }
        };

        return personer;
    }
}

The Year object simply wraps two int’s and a string. The Years object is a desperation shot from me looking like this:

public class Years : List<Year>{}

My XAML:

<DataGrid x:Name="TestGrid" ItemsSource="{Binding}" CanUserAddRows="False" AutoGenerateColumns="False">
    <DataGrid.Columns>
        <DataGridTextColumn Binding="{Binding Path=NumBuildings}" />
        <DataGridTextColumn Binding="{Binding Path=Taxed}" />
        <DataGridTextColumn Binding="{Binding Path=Area}" />
    </DataGrid.Columns>
</DataGrid>

This code generates this:

Result View

As you can see, the Year objects are bound to one property per column while I would essentially like to have them bound to one object with all properties in a single column. Unfortunately my WPF skills are lacking here. 🙁

  • 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-06-04T06:13:10+00:00Added an answer on June 4, 2026 at 6:13 am

    I found this article which talks about creating a datatable and transposing it (i.e. swapping the rows for columns) and then binding that object to the datagrid. So write a method that creates a transposed datatable from your collection and bind this table to the datagrid.

    The problem is that this won’t really update, so if your data is supposed to be edited by the user in the datagrid, then you kinda have a problem.

    You can either change your datasource directly, or you might have to edit the ControlTemplate of the datagrid.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am currently running into a problem where an element is coming back from
I want use html5's new tag to play a wav file (currently only supported
I would like to run a str_replace or preg_replace which looks for certain words
I have a French site that I want to parse, but am running into
I have some data like this: 1 2 3 4 5 9 2 6
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.