Search code examples
c#wpflistbuttonwrappanel

Add buttons from a wrap panel to array of buttons


Is there a way to add buttons from a specific wrappanel to an array or list in code? I tried the code below, but it doesn't work:

foreach(Button b in nameOfWrappanel)
{
    list.Add(b);
}

Solution

  • You have to specify wrappanel.children to access its child.

    foreach (Button b in nameOfWrappanel.Children)
    {
        list.Add(b);
    }