Resource management when changing window content

前端 未结 2 1908
有刺的猬
有刺的猬 2021-01-19 05:22

First of all, I do not feel completely educated on how to navigate between multiple \"pages\" of a window.

For example, I have a Window called MainWindow. Inside of

相关标签:
2条回答
  • 2021-01-19 05:31

    Instead of toggling visibility off and on, you should put a contentControl and switch it's contents to different UserControls.

    That way there's no reference to the UserControl that's offscreen, and you can handle memory issues better.

    0 讨论(0)
  • 2021-01-19 05:53

    One alternative is to just use a single ContentPresenter, and put your individual "panels" in there, but only one at a time.

    Instead of flipping visibility, you could use Data Binding to change the bound content within the ContentPresenter. This would only leave a single "view" in place at a time, preventing the neeed for "a large number" of panels to be loaded.

    0 讨论(0)
提交回复
热议问题