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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:33:19+00:00 2026-05-14T07:33:19+00:00

What is the best way to display multidimensional data in WPF? I won’t know

  • 0

What is the best way to display multidimensional data in WPF? I won’t know the size/shape of the data until runtime. Ideally I would like to use databinding but that is not a strict requirement. I was thinking some sort of grid but I don’t know how to dynamically bind to the data and have it figure out the number of rows and columns. Suggestions and examples please?

  • 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-14T07:33:19+00:00Added an answer on May 14, 2026 at 7:33 am

    Sounds as though you want an Excel-like interface for 2D arrays with editing capability. For the other dimensions, you will have to come up with tabs or a series of comboboxes.

    Check out the WPF Toolkit DataGrid. There is an option for auto generate columns. Experiment with that.

    However, you will have some code behind to deal with the other dimensions since the Datagrid can only represent 2D data.

    Corey

    Edit: (04/28/2010) Here is a working solution.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Windows;
    using System.Windows.Data;
    using Microsoft.Windows.Controls;
    
    namespace WpfApplication2
    {
        public partial class MainWindow : Window
        {
        public List<List<object>> TheData { get; set; }
    
        public MainWindow()
        {
            InitializeComponent();
    
            // Generate some random data
            Random r = new Random();
    
            TheData = new List<List<object>>
            {
                new List<object> { r.Next(100), r.Next(100), r.Next(100),r.Next(100) },
                new List<object> {  r.Next(100), r.Next(100), r.Next(100),r.Next(100) },
                new List<object> {  r.Next(100), r.Next(100), r.Next(100) },
                new List<object> {  r.Next(100), r.Next(100), r.Next(100),r.Next(100) },
                new List<object> {  r.Next(100), r.Next(100), r.Next(100),r.Next(100) },
                new List<object> {  r.Next(100), r.Next(100), r.Next(100),r.Next(100), r.Next(100) }
            };
    
            // Now bind data to the grid
            // We need at least one element
            if (TheData.Count > 0)
            {
                // Find the longest row so we create enough columns
                var max = TheData.Max(c => c.Count);
    
                for (var i = 0; i < max; i++)
                {
                    TheGrid.Columns.Add(
                        new DataGridTextColumn
                        {
                            Header = string.Format("Column: {0:00}", i),
                            Binding = new Binding(string.Format("[{0}]", i))
                        }
                        );
                }
            }
    
            TheGrid.ItemsSource = TheData;
        }
    }
    

    }

    The XAML…

    <Window x:Class="WpfApplication2.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:toolkit="http://schemas.microsoft.com/wpf/2008/toolkit"
        Title="GridTest">
    <Grid x:Name="LayoutGrid">
        <toolkit:DataGrid x:Name="TheGrid"
                          AutoGenerateColumns="False"
                          IsReadOnly="False"
                          CanUserAddRows="False"/>
    </Grid>
    

    Some thing to note about this approach, if you allow editing of data and allow jagged arrays, you will need to new up a new List on the short rows.

    As far as > 2D data, you will need some sort of option to select another dimension since the datagrid can only represent 2D data.

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

Sidebar

Related Questions

I would like to know the best way to display flash messages in Kohana
What would be the best way to display & program simple game board (say
What would be the best way to display an animation while waiting for server-side
What is the best way to display multi-columned data in a grid format using
Could anyone please advise me what would be the best way to display the
I'd like to know what is the best way to display all MessageHeaders server
hows the best way to display comments/user data from a db using mvc? do
What would be the best way to display items in c# in a form
What is the best way to display results and data coming from Database in
Im just wondering what would the best way to display multiple instances of a

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.