1

G'day folks

This is probably an easy one for you lot, but i'm curious...

If you hide a say for example a stackpanel using visibility.collapsed, does it remove it from memory?

if not, what would be the best and/or easiest way to remove say a stackpanel from memory, but be able to show it again easily?

I do understand i could just recreate the SP in the code-behind, but i'm wondering if there is an easy way?

I have thought of making the SP an usercontrol, or did i just answer my own question?

Edit:

Seems I did answer my own question, thanks Ben Voigt. And Now I know how to remove a child control thanks to Somesh Mukherjee, so it seems I can use both answers :)

Ubermonk
  • 101
  • 1
  • 8
  • 1
    When you say "show it again easily", do you mean it should remember any changes you or the user have made to its contents? That requires memory. – Ben Voigt Feb 08 '12 at 04:44
  • I mean like for example adding it like SP.Add or something similar without having to redefine what the SP was (basically just showing a copy of how it was first defined) – Ubermonk Feb 08 '12 at 04:49
  • Using a user control should help you there, since then you can call its constructor and add it back into the DOM. – Ben Voigt Feb 08 '12 at 04:51

1 Answers1

2

No it doesn't get removed from memory. You can use the remove method on canvas to remove it.

Remove Control from Window in WPF

Community
  • 1
  • 1
SoWhat
  • 5,564
  • 2
  • 28
  • 59