【问题标题】:Universal Windows Platform Page KeepAlive通用 Windows 平台页面 KeepAlive
【发布时间】:2015-09-15 17:13:59
【问题描述】:

在通用 Windows 平台中,有没有办法让页面保持活动状态?因此,假设我正在输入一个新客户,并且在某个时候我意识到我要分配的类别尚未创建,所以我想导航到另一个页面以添加该类别,但我不希望当前页面被破坏并丢失数据。在 WPF 中,此场景使用 PRISM KeepAlive 非常简单。

谢谢

【问题讨论】:

    标签: wpf xaml uwp


    【解决方案1】:

    您可以通过设置NavigationCacheMode 属性来缓存页面及其内容。这个属性的默认设置是Disabled,所以你必须在你的构造函数中手动设置它:

    public MyPage()
    {
        // The page will only be cached,
        // if the cache size of the parent Frame is large enough for this page
        NavigationCacheMode = NavigationCacheMode.Enabled;
    
        // The page will always be cached,
        // even if it exceeds the cache size of the parent Frame
        NavigationCacheMode = NavigationCacheMode.Required;
    }
    

    有关更多详细信息,请查看 MSDN 上的 Quickstart: Navigating between pages 主题。

    【讨论】:

    • 谢谢你的回答,今晚我会检查它:)
    猜你喜欢
    • 2016-10-07
    • 2016-11-26
    • 2016-11-06
    • 2016-01-10
    • 2015-10-29
    • 1970-01-01
    • 2016-04-09
    • 1970-01-01
    相关资源
    最近更新 更多