Write device platform specific code in Xamarin.Forms

前端 未结 5 1383
野性不改
野性不改 2020-12-07 18:57

I have the following Xamarin.Forms.ContentPage class structure

public class MyPage : ContentPage
{
    public MyPage()
    {
        //do work t         


        
5条回答
  •  囚心锁ツ
    2020-12-07 19:47

    This seems less about Xamarin.Forms and more about using defaults in a PCL. Check out James Montemagno's github repo for doing cross-platform defaults.

    Then just call his static methods for setting/retrieving. The nuget package is Xam.Plugins.Settings.

    It can be used like this:

    using Refractored.Xam.Settings;
    

    ...

    CrossSettings.Current.AddOrUpdateValue("AccessToken", accessToken);
    var value = CrossSettings.Current.GetValueOrDefault("AccessToken");
    

提交回复
热议问题