views:

15

answers:

1

How to clear all usercontrols in the wpf window. in runtime i added dynamic usercontrols in my wpf window, when i refresh, i want to clear all those and need to load again. so how i can clear all usercontrols in my page.??

A: 

The Window class itself has a single child which you can clear by setting the Content property to null. If you added the controls to a Panel, such as a Grid or Canvas, then you can clear them by calling the Clear method on the Children property:

myCanvas.Children.Clear();
Quartermeister