I'm having a whole lot of difficulty attempting to add data to a multi-column ListView

Here's the code for the ListView

ListView Height="263" Margin="12,29,12,0" Name="Tasks_ListView" VerticalAlignment="Top" ItemsSource="{Binding Source=}">
            <ListView.View>
                <GridView>
                    <GridViewColumn  Width="91" DisplayMemberBinding="{Binding CourseName}"  Header="Class Name" />
                    <GridViewColumn Width="275" Header="Assignment Name" DisplayMemberBinding="{Binding AssignmentName}"/>
                    <GridViewColumn Width="110" Header="Due Date" DisplayMemberBinding="{Binding Path=Due_Date}"/>
                    <GridViewColumn Width="184" Header="Unit" DisplayMemberBinding="{Binding Unit}"/>
                </GridView>
            </ListView.View>
        </ListView>

Here's the data I want to add

foreach (Course Courses in CurrentUser.Course)
            {
                foreach (Assignment SelectedAssignment in Courses.CurrentUnit.Assignments)
                {
                    ListViewItem CourseName = new ListViewItem();
                    ListViewItem AssignmentName = new ListViewItem();
                    ListViewItem DueDate = new ListViewItem();
                    ListViewItem UnitName = new ListViewItem();
                    CourseName.Name = Courses.Name;
                    AssignmentName.Name = SelectedAssignment.Name;
                    DueDate.Name = SelectedAssignment.Due_Date.ToString();
                    UnitName.Name = Courses.CurrentUnit.Name;
                    Tasks_ListView.Items.Add(CourseName);
                }
            }

Here is a simple example of how to populate listView. I have put all together into one method, but its better to put the column creations into form load (so it loads only one time).
This is the code:

private void PopulatingListView()
        {
            this.listView1.Items.Clear();

            this.listView1.Columns.Add("1st column", 75, HorizontalAlignment.Left);
            this.listView1.Columns.Add("2nd column", 75, HorizontalAlignment.Left);
            this.listView1.Columns.Add("3rd column", 75, HorizontalAlignment.Left);
            this.listView1.View = View.Details;
            this.listView1.FullRowSelect = true;

            int[] array1 = new int[] { 1, 2, 3, 4, 5 };
            string[] array2 = new string[] { "A", "B", "B", "D", "E" };
            string[] array3 = new string[] { "A1", "B2", "C3", "D4", "E5" };

            for (int i = 0; i < 5; i++)
            {
                ListViewItem lvi = new ListViewItem(array1[i].ToString());
                lvi.SubItems.Add(array2[i]);
                lvi.SubItems.Add(array3[i]);
                this.listView1.Items.Add(lvi);
            }
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.