Note that there are some explanatory texts on larger screens.

plurals
  1. POHow To Bind Multiple Arrays to a DataGrid
    primarykey
    data
    text
    <p>I've got a Character object, in which I've got 10 arrays, representing 10 statistics of the character (agility, strength, etc - this is for a role playing game). The arrays keep track of the stat and increases to it over time, so I know at which level they increased which stat. The arrays are finite, I keep track up to level 50, so I don't need the ability to track a variable number of rows or columns. Everything is fixed.</p> <p>e.g. string[] Agility = new string[50];</p> <p>I want to display this information in a DataGrid, and bind each cell in each row to an element of each stat array. I found and tried what I thought was my best hope, a library called DataGrid2D, but could not get it to work with my best effort. When I tried to change the value in the DataGrid I would get the error: Two-way binding requires Path or XPath. The 10x50 grid was populated when I selected the character from a ListBox, and even that took a couple seconds to populate.</p> <p>The DataGrid2D example was found here: <a href="https://stackoverflow.com/questions/276808/how-to-populate-a-wpf-grid-based-on-a-2-dimensional-array/4002409#4002409">How to populate a WPF grid based on a 2-dimensional array</a>. I used Meleak's answer (the 2nd one down), changing out m_intArray for a 2D array created from each of the stats (c.Stats).</p> <pre><code>var c = CE_Characters_charactersLB.SelectedItem as Character; var dg = CE_Characters_statsDG; dg.ItemsSource = GetBindable2DArray&lt;string&gt;(c.Stats); </code></pre> <p>Is there a solution that is more efficient? Or does anyone know why I get the Path error with DataGrid2D?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload