tags:

views:

522

answers:

2

I have created nearly 40 to 60 button controls dynamically on canvas control using WPF. Now I want to remove the selected button control from the canvas. How do I do this.

+3  A: 
canvas.Children.Remove(buttonInstance);
luvieere
This is preferable, as the GC will remove the instance (assuming it has no other references).
Alastair Pitts
A: 

The easiest would be to just hide it, then you don't have to worry about disposing it as that will be taken care of by the regular life cycle of the controls.

Guffa