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

  • Home
  • SEARCH
  • 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 8790027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:32:56+00:00 2026-06-13T22:32:56+00:00

In maine, on my button click event handler I do: private void addIconButton_Click(object sender,

  • 0

In maine, on my button click event handler I do:

    private void addIconButton_Click(object sender, EventArgs e)
    {
        if (test)
        {
            MessageBox.Show("enters addIcon Main");
            Note note = new Note();
            note.Modified = DateTimeOffset.Now;

            if (note != null)
            {
               Settings.NotesList.Add(note);  //this causes the issue. 

                //Settings.NotesList[0] = note;
            }
            Settings.CurrentNoteIndex = 0;
            test = false;

            MessageBox.Show("right before navigate");
            this.NavigationService.Navigate(new Uri("/DetailsPage.XAML", UriKind.Relative));
            MessageBox.Show("after navigate");

        }
        //DetailsPage mynewPage = new DetailsPage(); 
        //this.Content = mynewPage;

    }

and on my on navigatedTo I do:

    protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
    {
        MessageBox.Show("enters onNav Main");
        DataContext = null;
        DataContext = Settings.NotesList;


        Settings.CurrentNoteIndex = -1;
        Listbox.SelectedIndex = -1;


        if (Settings.NotesList != null)
        {
            if (Settings.NotesList.Count == 0)
            {
                Notes.Text = "No Notes";
            }
            else
            {
                Notes.Text = "";
            }
        }
    }

Inside my front end code I do:

 <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <ListBox x:Name="Listbox" SelectionChanged="listbox_SelectionChanged" ItemsSource="{Binding}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Border Width="800" MinHeight="60">
                        <StackPanel>
                            <TextBlock x:Name="Title" VerticalAlignment="Center" FontSize="{Binding TextSize}"  Text="{Binding Name}"/>
                            <TextBlock x:Name="Date"  VerticalAlignment="Center" FontSize="{Binding TextSize}"  Text="{Binding Modified, 
                                    Mode=TwoWay, Converter={StaticResource dateConverter}}"/>
                        </StackPanel>
                    </Border>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</Grid>

I have an observable collections in a static class where in the constructor I set it to:

public static class Settings
{
    public static ObservableCollection<Note> NotesList;
    static IsolatedStorageSettings settings;
    private static int currentNoteIndex;

    static Settings()
    {
        NotesList = new ObservableCollection<Note>();
        settings = IsolatedStorageSettings.ApplicationSettings;
        MessageBox.Show("enters constructor settings");
    }

and then inside the Notes class it just looks like this:

public class Note
{
    public DateTimeOffset Modified { get; set; }
    public string Title  { get; set; }
    public string Content { get; set; }
    public int TextSize { get; set; }

}

when I click the app button and it calls the invent handler right after the navigationService is called I get:

    // Code to execute on Unhandled Exceptions
    private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
    {
        if (System.Diagnostics.Debugger.IsAttached)
        {
            // An unhandled exception has occurred; break into the debugger
            System.Diagnostics.Debugger.Break();
        }
    }

this only happens when Settings.NotesList.Add(note); is added in the addIconButton_click method..

Any suggestions???

  • 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-13T22:32:57+00:00Added an answer on June 13, 2026 at 10:32 pm

    I fixed it by setting default values to the instance variables in the Notes class inside the constructor…

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

Sidebar

Related Questions

When I click on my app button, it goes into the selection event handler
I have a local thread that is started on button-click event from the main
Main Activity: private Button btnSubmit; private DataSource mDataSource; private Context mContext; @Override public void
In this very simplified and minimized example click event handler has been defined for
have you ever found a problem when assigning a click event handler for your
Project: http://design.vitalbmx.com/fave/news.html When I click Add to favorites button (under main pic), in Chrome
I have a main window with a Gtk Button named openDialog. If I click
I've created a button in my xml layout and followed with an onClick event
Imports System Imports System.Windows.Forms Class MyButtonClass Inherits Form Private mrButton As Button Public Sub
I have tried unbinding the click event, but it fires sometimes twice sometimes 5

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.