Spen D
Spen D

Reputation: 4345

clearing all usercontrol in the wpf window

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.??

Upvotes: 1

Views: 6759

Answers (1)

Quartermeister
Quartermeister

Reputation: 59139

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();

Upvotes: 3

Related Questions