How can I save some user data locally on my Xamarin Forms app?

前端 未结 5 659
太阳男子
太阳男子 2020-12-12 15:29

I have a simple Xamarin Forms app. I\'ve now got a simple POCO object (eg. User instance or an list of the most recent tweets or orders or whatever).

Ho

5条回答
  •  轮回少年
    2020-12-12 16:01

    If you want to store a simple value, such as a string, follow this Example code.

    setting the value of the "totalSeats.Text" to the "SeatNumbers" key from page1

    Application.Current.Properties["SeatNumbers"] = totalSeats.Text;
    await Application.Current.SavePropertiesAsync();
    

    then, you can simply get the value from any other page (page2)

    var value = Application.Current.Properties["SeatNumbers"].ToString();
    

    Additionally, you can set that value to another Label or Entry etc.

    SeatNumbersEntry.Text = value;
    

提交回复
热议问题