ユーザーがxamarin.formsアプリでこのフォームに入力するたびにwifi資格情報を入力する必要がないようにしたいと思います。ユーザーが最後にエントリに入力した値を保存できる方法を見つけようとしています。助言がありますか?
nullでなければフィールドに格納するのと同じくらい簡単だと思いましたが、「ステートメントとして使用できるのは、代入、呼び出し、インクリメント、デクリメント、待機、および新しいオブジェクト式のみです」というエラーが表示されます。
私のクラスのトップにはフィールドがあります。
string WifiNamePlaceholder;
その後、ページの後半にエントリがあります
if (WifiNamePlaceholder == null)
{
WifiNamePlaceholder = "Enter in your wifi credentials"
}
wifi_name = new Xamarin.Forms.Entry
{
BackgroundColor = Color.White,
Placeholder = WifiNamePlaceholder,
Margin = new Thickness(0, 0, 10, 0),
FontFamily = Fonts.HelveticaNeueBold,
FontSize = labelSize
}
//Attempt to set new value here but get error
//Doing this in hopes it can save their entry for next time.
wifi_name.Placeholder == WifiNamePlaceholder;
If you have any suggestions it would be greatly appreciated! Thank you!
Xamarin.Essentials.PreferencesまたはXamarin.Essentials.SecureStorageを使用します。それらは使いやすく、大量のオーバーヘッドを必要としません。
Xamarin.Essentials.Preferences.Get("Key", default(string));
Xamarin.Essentials.Preferences.Set("Key", "stringToSave")
次にEntry.Text
、保存されている値を使用して設定します。ドキュメントを参照してください:Xamarin.Essentials.Preferences
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加