我想使用设置存储在UWP中保存边框颜色。
将颜色存储为字符串:使用ToString
类的Color
方法将颜色转换为字符串,将ColorHelper.ToColor()
转换回UWP Community Toolkit:
private void SaveColor(Color color)
{
Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
localSettings.Values["color"] = color.ToString();
}
private Color LoadColor()
{
Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
return Microsoft.Toolkit.Uwp.Helpers.ColorHelper.ToColor((string) localSettings.Values["color"]);
}