Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can add GridViewColumns to the GridView dynamically given the first array using a method like this:</p> <pre><code>private void AddColumns(GridView gv, string[] columnNames) { for (int i = 0; i &lt; columnNames.Length; i++) { gv.Columns.Add(new GridViewColumn { Header = columnNames[i], DisplayMemberBinding = new Binding(String.Format("[{0}]", i)) }); } } </code></pre> <p>I assume the second array containing the values will be of ROWS * COLUMNS length. In that case, your items can be string arrays of length COLUMNS. You can use Array.Copy or LINQ to split up the array. The principle is demonstrated here:</p> <pre><code>&lt;Grid&gt; &lt;Grid.Resources&gt; &lt;x:Array x:Key="data" Type="{x:Type sys:String[]}"&gt; &lt;x:Array Type="{x:Type sys:String}"&gt; &lt;sys:String&gt;a&lt;/sys:String&gt; &lt;sys:String&gt;b&lt;/sys:String&gt; &lt;sys:String&gt;c&lt;/sys:String&gt; &lt;/x:Array&gt; &lt;x:Array Type="{x:Type sys:String}"&gt; &lt;sys:String&gt;do&lt;/sys:String&gt; &lt;sys:String&gt;re&lt;/sys:String&gt; &lt;sys:String&gt;mi&lt;/sys:String&gt; &lt;/x:Array&gt; &lt;/x:Array&gt; &lt;/Grid.Resources&gt; &lt;ListView ItemsSource="{StaticResource data}"&gt; &lt;ListView.View&gt; &lt;GridView&gt; &lt;GridViewColumn DisplayMemberBinding="{Binding Path=[0]}" Header="column1"/&gt; &lt;GridViewColumn DisplayMemberBinding="{Binding Path=[1]}" Header="column2"/&gt; &lt;GridViewColumn DisplayMemberBinding="{Binding Path=[2]}" Header="column3"/&gt; &lt;/GridView&gt; &lt;/ListView.View&gt; &lt;/ListView&gt; &lt;/Grid&gt; </code></pre>
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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