c# - WPF 页面如何保存在内存中?

标签 c# wpf visual-studio

例如,在我的程序中,我有一个名为 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/

相关文章:

c# - 如何开始在 C# 中制作音频和视频流应用程序

wpf - 如何在 WPF XAML 中制作加载图形?

wpf - 为什么在 Collection 更改时不调用 Converter?

wpf - 使用TemplateBinding更新源

c++ - 可以根据需要进行编译但不能运行的热键/按钮(在F5和Ctrl + Shift + B之间)

c# - 如何为按键拍摄添加延迟

c# - 长后台进程刷新 ui wpf

c# - 系统.Net.Mail.SmtpException : The SMTP server requires a secure connection or the client was not authenticated

C - 在 Visual Studio 中按值传递

c++ - 在 Visual C++ 中明确定义有符号整数溢出的选项?