What is the correct way to dispose of a WPF window?

前端 未结 4 2023
广开言路
广开言路 2020-12-05 17:00

I have a WPF window which I am creating from another window by calling Show(), then letting it Close() itself. When the window closes, I expect it

4条回答
  •  温柔的废话
    2020-12-05 17:48

    Closing the window and being confident that you have released all resources to it and any of its children will cause all well behaved elements in the logic tree to be garbage collected.

    I say "well behaved" because it's theoretically possible to have an element that does something like create a thread that isn't stopped properly, but in practice if you're using the basic WPF framework and well written controls, you should be fine to just release everything.

提交回复
热议问题