Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6806423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:42:31+00:00 2026-05-26T19:42:31+00:00

Simple question, asked before but no one gave me the right answer so I’m

  • 0

Simple question, asked before but no one gave me the right answer so I’m going to be very specific.

I need to read two settings form IsolatedStorage in Windows Phone. The settings are ExitAlert and OrientationLock. I have already set up the settings, they save just fine, I just need to know how to read them from another page. The page the variables are set on is Settings.cs, and I need to read the settings from MainPage.xaml.cs. I also need to know how to only do something if the variable is true or false. I think I’m supposed to use an if-then-else statement, but I just want to double check.

My app is written in C#. This is the code that I’m using to store the settings:

using System;
using System.IO.IsolatedStorage;
using System.Diagnostics;

namespace Google_
{
    public class AppSettings
    {

        IsolatedStorageSettings isolatedStore;

        // isolated storage key names
        const string ExitWarningKeyName = "ExitWarning";
        const string OrientationLockKeyName = "OrientationLock";

        // default values
        const bool ExitWarningDefault = true;
        const bool OrientationLockDefault = false;

        public AppSettings()
        {
            try
            {
                // Get the settings for this application.
                isolatedStore = IsolatedStorageSettings.ApplicationSettings;

            }
            catch (Exception e)
            {
                Debug.WriteLine("Exception while using IsolatedStorageSettings: " + e.ToString());
            }
        }


        public bool AddOrUpdateValue(string Key, Object value)
        {
            bool valueChanged = false;

            // If the key exists
            if (isolatedStore.Contains(Key))
            {
                // If the value has changed
                if (isolatedStore[Key] != value)
                {
                    // Store the new value
                    isolatedStore[Key] = value;
                    valueChanged = true;
                }
            }
            // Otherwise create the key.
            else
            {
                isolatedStore.Add(Key, value);
                valueChanged = true;
            }

            return valueChanged;
        }

        public valueType GetValueOrDefault<valueType>(string Key, valueType defaultValue)
        {
            valueType value;

            // If the key exists, retrieve the value.
            if (isolatedStore.Contains(Key))
            {
                value = (valueType)isolatedStore[Key];
            }
            // Otherwise, use the default value.
            else
            {
                value = defaultValue;
            }

            return value;
        }

        public void Save()
        {
            isolatedStore.Save();
        }

        public bool ExitWarning
        {
            get
            {
                return GetValueOrDefault<bool>(ExitWarningKeyName, ExitWarningDefault);
            }
            set
            {
                AddOrUpdateValue(ExitWarningKeyName, value);
                Save();
            }
        }

        public bool OrientationLock
        {
            get
            {
                return GetValueOrDefault<bool>(ExitWarningKeyName, OrientationLockDefault);
            }
            set
            {
                AddOrUpdateValue(OrientationLockKeyName, value);
                Save();
            }
        }

    }
}

If anything is unclear, just let me know so I can explain further. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:42:32+00:00Added an answer on May 26, 2026 at 7:42 pm

    What I do is add the following to my AppSettings class:

    private static AppSettings _default = new AppSettings();
    /// <summary>
    /// Gets the default instance of the settings
    /// </summary>
    public static AppSettings Default
    {
        get
        {
            return _default; 
        }
    }
    

    Then you can just use AppSettings.Default from anywhere in your project:

    if (AppSettings.Default.ExitWarning)
    {
    }
    else
    {
    }
    

    Let me know if you need more information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well looks too simple a question to be asked but i asked after going
I have asked a similar question before, but didn't get very good results. I've
I asked a question related to this one previously but I need to know
I realize this question is very likely to have been asked before, but I've
i have simple question may be someone asked it before me but i could
Simple question, but one that I've been curious about...is there a functional difference between
The same question has been asked before but the solutions don't work for me.
I have asked this question before - but I have spent some time thinking
This question may have been asked before, but I'm starting to get into game
I apologize if this question was asked already before but I could not find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.