Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How to use for loop - in MainWindowViewModel

$
0
0

Hi all,I have created something, but I need to put it into a loop. Because I will use a database so every new Client (Parent in code) will be added into a loop.

link to project, in OneDrive : link

My code >

public MainWindowViewModel()
        {
            Parents = new ObservableCollection<Parent>
            {
                new Parent { ParentName="Daddy",
                    Children = new ObservableCollection<Child>
                    {
                        new Child { ChildName = "Daddy A" },
                        new Child { ChildName = "Daddy B" },
                        new Child { ChildName = "Daddy C" },
                        new Child { ChildName = "Daddy D" }
                    }
                },
               new Parent { ParentName="Mummy",
                    Children = new ObservableCollection<Child>
                    {
                        new Child { ChildName = "Mummy X" },
                        new Child { ChildName = "Mummy Y" }
                    }
                }
            };
        }
Thanks for answers.




Viewing all articles
Browse latest Browse all 18858

Trending Articles