如何在xamarin的内容页面中“存储”对象或json?

问题描述 投票:0回答:1

我有一个带有导航页面和一些内容页面的应用程序。这些内容页面之一从Web下载json字符串。每次调用此页面时都无需下载此json。如何存储json的最佳方法?当前,我将其存储到Application.Current.Properties,但是不需要持久性。

c# xamarin
1个回答
0
投票

只需在App类中创建一个属性,它将通过App.Current提供

App.xaml.cs

public string MyCustomProperty { get; set; }

您应用中的任意位置

var value = ((App)App.Current).MyCustomProperty;
© www.soinside.com 2019 - 2024. All rights reserved.