protected override void OnDisappearing()
        {
            // Only save it if there's some text somewhere.
            if (!String.IsNullOrWhiteSpace(note.Title) ||
                !String.IsNullOrWhiteSpace(note.Text))
            {
                note.SaveAsync();

                if (!isNoteEdit)
                {
                    App.NoteFolder.Notes.Add(note);
                }
            }

            // Detach handlers for Suspending and Resuming events.
            helper.Suspending -= OnSuspending;
            helper.Resuming   -= OnResuming;

            base.OnDisappearing();
        }
        async protected override void OnDisappearing()
        {
            base.OnDisappearing();

            // Special code for iOS:
            //      Do not save note when program is terminating.
            if (isInSleepState)
            {
                return;
            }

            // Only save the note if there's some text somewhere.
            if (!String.IsNullOrWhiteSpace(Note.Title) ||
                !String.IsNullOrWhiteSpace(Note.Text))
            {
                // Save the note to a file.
                await Note.SaveAsync();

                // Add it to the collection if it's a new note.
                NoteFolder noteFolder = ((App)App.Current).NoteFolder;

                // IndexOf method finds match based on Filename property
                //      based on implementation of IEquatable in Note.
                int index = noteFolder.Notes.IndexOf(note);
                if (index == -1)
                {
                    // No match -- add it.
                    noteFolder.Notes.Add(note);
                }
                else
                {
                    // Match -- replace it.
                    noteFolder.Notes[index] = note;
                }
            }
        }