I'm going to be focusing on the second section of your code, as that seems to be the portion that is actually causing trouble. Unfortunately there are a few details missing, so I'll be making some assumptions on intent, type, etc.
Here is the .xaml I'll be working against:
<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<ListView x:Name="myListView" HorizontalAlignment="Left" Height="301" Margin="10,10,0,0" VerticalAlignment="Top" Width="498">
<ListView.View>
<GridView>
<GridViewColumn/>
</GridView>
</ListView.View>
</ListView>
</Grid>
</Window>
And here is my interpretation of that chunk of C#:
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
namespace WpfApp1
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
var myListViewVar = this.FindName("myListView") as ListView;
string[] rowItems = new string[10];
for (int i = 0; i < 10; i++)
{
rowItems[i] = i.ToString();
}
var item = new ListViewItem { Content = rowItems };//You are adding your string array to a singular element. It does not want it. It wants a nice string.
var itemsList = new List<ListViewItem>();//You then wrap this singular item in a list. I'm inferring the type here, since the rest of your code does not reference it.
itemsList.Add(item);
myListViewVar.Items.Add(item);//You then add the ARRAY to the list of items. Again, this is not desired. See https://msdn.microsoft.com/en-us/library/system.windows.forms.listview.items(v=vs.110).aspx for usage examples.
}
}
}
As explained above, WPF doesn't know how to stringify your array. Interpreting from what the rest of your code implies, what I think you want is:
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
namespace WpfApp1
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
var myListViewVar = this.FindName("myListView") as ListView;
string[] rowItems = new string[10];
for (int i = 0; i < 10; i++)
{
rowItems[i] = i.ToString();
}
for (int i = 0; i < 10; i++)
{
var item = new ListViewItem { Content = rowItems[i] };//Each ListViewItem holds an individual string rather than an array
myListViewVar.Items.Add(item);//Then add that ListViewItem.
}
}
}
}
Obviously this has a redundancy in the form of the second loop, but I wanted to keep with your code where you store everything outside of the loop.
As for data binding, I'd recommend looking at WPF Binding to local variable
I don't use WPF too often, but it looks like what you want.
Hope this helps. Let me know if I've missed the mark on what you're intending.