Children.Clear() vs. Children.RemoveAt(i)

njsokalski

Well-known member
Joined
Mar 16, 2011
Messages
102
Programming Experience
5-10
I have a StackPanel in a Windows Phone 7 app, and I need to remove all the StackPanel's child controls. I have tried this using a for loop with the Children.RemoveAt(i) method and I have tried it using the Children.Clear() method. Both methods seem to be removing the controls, but with the Children.Clear() method I can still see the background color of the StackPanel, which I do not see afterwards when using Children.RemoveAt(i). I am assuming this means that with Children.Clear() the StackPanel is not being resized afterwards. Is there something I need to do to make the StackPanel act the same with Children.Clear() as it does with Children.RemoveAt(i)? Thanks.
 
Back
Top