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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:10:04+00:00 2026-05-24T05:10:04+00:00

I have to List of Data : List<string[]> dataRow = new List<string[]>(); every string[]

  • 0

I have to List of Data :

List<string[]> dataRow = new List<string[]>();
  1. every string[] array are full with 30 data for each row.
  2. Column Name are already exists.

I’m trying to display it like this :

XAML :

<DataGrid Margin="8,259,8,8" IsReadOnly="True" AutoGenerateColumns="False" AlternatingRowBackground="Gainsboro"  AlternationCount="2" Name="MyDataGrid" />

C# :

MyDataGrid.ItemsSource = dataRow;

foreach( string[] cellContent in dataRow )
{
  foreach( string text in cellContent )
  {
    var column = new DataGridTextColumn
    {
      Binding = new Binding(text)
    };
    MyDataGrid.Columns.Add(column);
   }
 }

but i got a “ContextSwitchDeadlock” Error. How can i solve this?

Thank u for Helping

EDIT : solved but not with the databinding Way

I solved it like this :

List<string> ColumnName = new List<string>();
List<string[]> dataRow = new List<string[]>();
DataTable myTable = new DataTable();

 // Fill Array ColumnName and dataRow Here

foreach (string text in ColumnName)
{
   myTable.Columns.Add(text);
}
foreach (string[] cellContent in dataRow)
{
   myTable.Rows.Add(cellContent);
}
DatensatzGrid.ItemsSource = myTable.AsDataView();

Thank u for all the reply!!

  • 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-24T05:10:04+00:00Added an answer on May 24, 2026 at 5:10 am

    The DataGrid control doesn’t support Binding to 2D arrays, List<List..>> etc.

    See this question: How to populate a WPF grid based on a 2-dimensional array

    I created a subclassed DataGrid (DataGrid2D) to achieve this a while back.

    To use it just add a reference to DataGrid2DLibrary.dll, add this namespace

    xmlns:dg2d="clr-namespace:DataGrid2DLibrary;assembly=DataGrid2DLibrary"
    

    and then create a DataGrid2D and bind it to your IList, 2D array or 1D array like this

    <dg2d:DataGrid2D Name="MyDataGrid"
                     ItemsSource2D="{Binding DataRow}"/>
    

    Since dataRow is a field a not a property binding won’t work, but just setting the ItemsSource2D in code behind will be enough to display it

    MyDataGrid.ItemsSource2D = dataRow;
    
    • DataGrid2D Library
    • DataGrid2D Source
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: TEST.DATA.Data.COR.Point,2;TEST.DATA.Data.COR.Point,5;TEST.DATA.Data.COR.Point,12;TEST.DATA.Data.COR.Point,12;TEST.DATA.Data.COR.WordTOFIND,18 I have a list of array with
I have list of strings var data = new List<string> {Name1, Surname1, Name2, Surname2
I have a list of data that is a schedule. Each item has a
I have my strings in a String array, my Data in a datatable. What
I have a list of data where I keep e.g. countries with code, name
I have a list of data that I want to search through. This new
I have a string comma separated list of some data. I have another list
I have a list of data as shown below Original Data Genre Name Year
I have the following piece of code: DataRow CreateRow(DataTable dt, string name, string country)
Hi all I have problem with following: foreach (DataRow dr in data.Tables[0].Rows) { string

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.