IsolatedStorageSettings in Windows Phone

IsolatedStorageSettings



Save Data Into Setting:
/// <summary>
/// Save Value into Setting File
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, RoutedEventArgs e)
{
IsolatedStorageSettings.ApplicationSettings.Add("Email", txtname.Text);
}

Retrieve Data from Setting:

/// <summary>
/// Retrieve Value from Setting file
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

private void button2_Click(object sender, RoutedEventArgs e)
{
if (IsolatedStorageSettings.ApplicationSettings.Contains("Email") == true)
{
txtemail.Text = IsolatedStorageSettings.ApplicationSettings["Email"].ToString();
}
else
{
MessageBox.Show("Value not found");
}
}

Save Object into Setting:

/// <summary>
/// Class have two property
/// </summary>

public class Student
{
public string Name { get; set; }
public string email { get; set; }
}

/// <summary>
/// Store object into Setting
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

private void button1_Click_1(object sender, RoutedEventArgs e)
{
Student os = new Student { Name = txtname.Text, email = txtemail.Text };

IsolatedStorageSettings.ApplicationSettings.Add("Stud", os);
}
Retieve Object from setting

/// <summary>
/// Retrieve Object from Setting
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

private void button2_Click_1(object sender, RoutedEventArgs e)
{
Student os;
IsolatedStorageSettings.ApplicationSettings.TryGetValue<Student>("Stud", out os);
txtname.Text = os.Name;
txtemail.Text = os.email;
}

Data Binding

Student os;
IsolatedStorageSettings.ApplicationSettings.TryGetValue<Student>("Stud", out os);
txtname.Text = os.Name;
txtemail.Text = os.email;
this.DataContext = os;

<TextBlock Height="39" HorizontalAlignment="Left" Margin="90,439,0,0" Name="txtbname" Text="{Binding Name}" VerticalAlignment="Top" Width="251" />

<TextBlock Height="36" HorizontalAlignment="Left" Margin="90,509,0,0" Name="txtbemail" Text="{Binding email}" VerticalAlignment="Top" Width="263" />

0 Comments

Featured Post

AI Evolution Explained: GenAI vs LLMs vs AI Agents vs Agentic AI vs Intelligent AI

Artificial Intelligence (AI) is one of the most exciting technologies in our world today. But the terms that come with it like GenAI, LLMs, ...

MSDEVBUILD - English Channel

MSDEVBUILD - Tamil Channel

Popular Posts