Remove all child elements from a StackPanel

user1597524 picture user1597524 · Sep 7, 2012 · Viewed 18.9k times · Source

I have the following xaml code:

//some code
<ListBox>
<StackPanel Name="Mess">
</StackPanel>
</ListBox>

Then I add elements to StackPanel.

But at a given moment I need to remove all child elemnts of Mess. How can I do it?

Answer

petro.sidlovskyy picture petro.sidlovskyy · Sep 7, 2012

Please try

Mess.Children.Clear();