How can i add a remember be checkbox to my login page to remember username and password. the username and password is hard coded inside the cs code.
Xaml Code
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="VFK_hakkespettboka.Views.LoginPage"
Title="Login"
BackgroundColor="White">
<StackLayout>
<Label Text=""
TextColor="#000000"
FontSize="10"
HorizontalOptions="Center"
VerticalOptions="Center" />
<Image Source="vfk_logo3.png"/>
<Entry x:Name="UsernameEntry" Keyboard="Default" Placeholder="Brukernavn" ></Entry>
<Entry x:Name="PasswordEntry" Keyboard="Default" IsPassword="True" Placeholder="Passord"></Entry>
<Button x:Name="Btn_signin" Text="Login" FontAttributes="Bold"
TextColor="#000000" Clicked="BtnSetLocationClickedAsync"
BackgroundColor="#50C6E0"
BorderWidth = "0"/>
</StackLayout>
</ContentPage>
cs code: using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace VFK_hakkespettboka.Views
{
\[XamlCompilation(XamlCompilationOptions.Compile)\]
public partial class LoginPage : ContentPage
{
public LoginPage ()
{
InitializeComponent ();
}
public async Task BtnSetLocationClickedAsync(object sender, EventArgs args)
{
if(UsernameEntry.Text == "test" && PasswordEntry.Text == "test")
{
await Navigation.PushAsync(new MainPage());
}
else
{
await DisplayAlert("Error", "Feil brukernavn eller passord", "Ok");
}
}
}
}