I need to collect and display a WPF data grid from a set of array of strings that I got from txt. The problem is that I do not know a priori what will be the number of columns, i.e. The number of elements in one array. So I defined in my xaml<DataGrid Grid.Row="2" ItemsSource="{Binding Path=Rows}" />
I tried to fill it in my view model, but I can’t just put my Observable Collection from the array as the source of the element, since only empty rows will be displayed in the datagrid.
I can also use a different approach in the Observable collection, since I create my array in the same method
this is my observable collection:
ObservableCollection<string[]> Rows = new ObservableCollection<string[]>;
in this method, I populate the collection
foreach(ListViewItem item in wsettings.lista)
{
TextBlock line = item.Content as TextBlock;
string txt = line.Text;
string[] x = txt.Split(stringSeparators, StringSplitOptions.None);
Rows.Add(x);
}
, . , ( ).
EDIT1:
EDIT2: ,