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 8530729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:19:00+00:00 2026-06-11T09:19:00+00:00

I’m encountering a problem with my WP7 app: I’m trying to make a login

  • 0

I’m encountering a problem with my WP7 app:

I’m trying to make a login page prompt only when the app can’t detect any stored username or password values; however, I keep running into a NullReferenceException when I try to navigate to my login page.

My code looks like this, and it’s in the contructor:

if (!checkLogin())
    {
        NavigationService.Navigate(new Uri("/LoginPage.xaml", UriKind.Relative));
    }

And checkLogin is just a function that returns either true or false depending or not the isolated storage settings are set correctly.

Anybody have any suggestions?

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-06-11T09:19:02+00:00Added an answer on June 11, 2026 at 9:19 am

    Here is what i think you want to do (From Peter Torr’s blog).

    If you need more clarification here is a piece of code to illustrate that. Assume there are 2 pages A.XAML and B.xaml and you would want to detect in whether to load A.xaml or B.xaml based on checking some login credentials which is stored in the IsolatedStorage,

    in App.xaml.cs of your project overwrite public App() with:

        public App()
        {
            // Global handler for uncaught exceptions. 
            UnhandledException += Application_UnhandledException;
    
            // Standard Silverlight initialization
            InitializeComponent();
    
            // Phone-specific initialization
            InitializePhoneApplication();
    
            // Show graphics profiling information while debugging.
            if (System.Diagnostics.Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = true;
    
                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;
    
                // Enable non-production analysis visualization mode, 
                // which shows areas of a page that are handed off to GPU with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;
    
                // Disable the application idle detection by setting the UserIdleDetectionMode property of the
                // application's PhoneApplicationService object to Disabled.
                // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
                // and consume battery power when the user is not using the phone.
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }
    
            RootFrame.Navigating += new NavigatingCancelEventHandler(RootFrame_Navigating);
        }
    
        void RootFrame_Navigating(object sender, NavigatingCancelEventArgs e)
        {
            if (e.Uri.ToString().Contains("/MainPage.xaml") != true)
            {
                return;
            }
            e.Cancel = true;
            RootFrame.Dispatcher.BeginInvoke(delegate
            {
                if (System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings.Contains("Login_Credentials"))
                {
                    RootFrame.Navigate(new Uri("/B.xaml", UriKind.Relative));
                }
                else
                {
                    RootFrame.Navigate(new Uri("/A.xaml", UriKind.Relative));
                }
            });
        }
    

    Then create the 2 dummy pages A.xaml and B.xaml so that for A.xaml you have some logic for saving the login credentials (in this case just a boolean flag):

    A.XAML:

    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
    
        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="A Page" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>
    
        <!--ContentPanel - place additional content here-->
        <StackPanel x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Button Content="Save Login Creds" Click="SaveLoginCreds"/>
        </StackPanel>
    </Grid>
    

    A.XAML.cs:

    private void SaveLoginCreds(object sender, RoutedEventArgs e)
    {
        System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings.Add("Login_Credentials", true);
    }
    

    Now, when you run the application for the first time, it will load A.xaml because it could not find any login credentials. Then if you click on the button, it will save the login credentials data in IsolatedStorage. Next time, you start the app it will load B.xaml because it detected the login credentials.

    I hope this helps.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

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.