SettingsXForm 1.0.0
See the version list below for details.
dotnet add package SettingsXForm --version 1.0.0
NuGet\Install-Package SettingsXForm -Version 1.0.0
<PackageReference Include="SettingsXForm" Version="1.0.0" />
paket add SettingsXForm --version 1.0.0
#r "nuget: SettingsXForm, 1.0.0"
// Install SettingsXForm as a Cake Addin #addin nuget:?package=SettingsXForm&version=1.0.0 // Install SettingsXForm as a Cake Tool #tool nuget:?package=SettingsXForm&version=1.0.0
XFormSettings
A nuget to improve settings storage (locally and eventually in the cloud) on .NETStandard Xamarin.Forms projects.
There is also an Maui
version, which can be found here.
https://github.com/AndreasReitberger/MauiSettings
The plugin idea is based on the Advexp.Settings.Local nuget by Alexey Ivakin</br> Repo: https://bitbucket.org/advexp/component-advexp.settings/src/master/</br> License: Apache-2.0 (https://licenses.nuget.org/Apache-2.0)</br>
This project was created from scratch, however uses the basic idea to keep all Settings in the static object. All taken and changed files have been marked so.
Nuget
Get the latest version from nuget.org<br>
Usage
Settings Object
In the .NET MAUI project, create a new Class
(for instance SettingsApp.cs
) holding your setting properties.
public partial class SettingsApp : XFormSettings<SettingsApp>
{
#region Settings
#region Version
[XFormSetting(Name = nameof(App_SettingsVersion))]
public static Version App_SettingsVersion { get; set; } = new("1.0.0");
#endregion
#region CloudSync
[XFormSetting(Name = nameof(Cloud_ShowInitialPrompt), DefaultValue = true)]
public static bool Cloud_ShowInitialPrompt { get; set; }
[XFormSetting(Name = nameof(Cloud_ShowInitialPrompt), DefaultValue = SettingsStaticDefault.Cloud_EnableSync)]
public static bool Cloud_EnableSync { get; set; }
#endregion
#region Theme
[XFormSetting(Name = nameof(Theme_UseDeviceDefaultSettings), DefaultValue = SettingsStaticDefault.General_UseDeviceSettings)]
public static bool Theme_UseDeviceDefaultSettings { get; set; }
[XFormSetting(Name = nameof(Theme_UseDarkTheme), DefaultValue = SettingsStaticDefault.General_UseDarkTheme)]
public static bool Theme_UseDarkTheme { get; set; }
[XFormSetting(Name = nameof(Theme_PrimaryThemeColor), DefaultValue = SettingsStaticDefault.Theme_PrimaryThemeColor)]
public static string Theme_PrimaryThemeColor { get; set; }
#endregion
#region Localization
[XFormSetting(Name = nameof(Localization_CultureCode), DefaultValue = SettingsStaticDefault.Localization_Default)]
public static string Localization_CultureCode { get; set; }
#endregion
#endregion
}
Load
To load the settings from the storage, call SettingsApp.LoadSettings()
(mostly in the App
constructor of your App.xmls file. The project uses the Xamarin.Essentials.Preferences
in order to store the settings on the corresponding device.
Save
Whenever you do make changes to a settings property of your class, call SettingsApp.SaveSettings()
. This will write the settings to the storage.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Newtonsoft.Json (>= 13.0.3)
- Xamarin.Essentials (>= 1.8.1)
- Xamarin.Forms (>= 5.0.0.2622)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.