例如,在我的程序中,我有一个名为 MainWindow 的窗口。在这个窗口中,我有一个框架,我使用导航菜单上的 mousedown 事件将页面加载到该框架中。
如果我调用第 1 页,如果我决定将另一个页面(比如第 2 页)加载到该框架中,会发生什么情况?旧页面是否保存在内存中?还是会被删除?
最佳答案
默认情况下,页面会被删除,但设置 KeepAlive
属性设置为 true
会将其保存在内存中。
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowTitle="WillBeKeptInMemory"
KeepAlive="True"
>
关于c# - WPF 页面如何保存在内存中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54844836/