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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:06:36+00:00 2026-05-23T22:06:36+00:00

I am a beginner and I am creating an application for Wndows Phone 7.

  • 0

I am a beginner and I am creating an application for Wndows Phone 7.

The first thing you must know is that my code works very well when I first load the page (from Menu to ConversationPage, with a Menu that contains a list of conversations). Then if I use the hardbutton to go back to the Menu page, and click on the same conversation to load same ConversationPage again, the problem start occuring.

Basically, I have a textbox called MessageBoxMessage, and a SendButton in the applicationBar.

What I want is: when I click the SendButton, it looks at MessageBoxMessage.Text and sends that value in the PostToWeb function.

Problem: when I reload the page, write something in the box and click SendButton, the MessageBoxMessage.Text changes magically to either “” or “new message”.

I have introduce a breakpoint in the MessageBoxMessage_TextChanged event and at the beginning of SendButton_Click event and the value comes from “blablabla” (lastest time MessageBoxMessage_TextChanged fired) to “” or “new message” (when SendButton_Click fire).

I can’t understand why… And I have another issue that cascade so I guess it’s big beginner issue…
(BTW I have checked and the event are defined only once)

Sorry for my english, I hope you’ll be able to help 🙂
Many thanks

private void MessageBoxMessage_GotFocus(object sender, RoutedEventArgs e)
    {
        MessageBoxMessageHasFocus = true;

        if (MessageBoxMessage.Text == "new message")
        {
            MessageBoxMessage.Text = "";

            if (hasPictureAttached == true)
            { SendButton.IsEnabled = true; }
            else
            { SendButton.IsEnabled = false; }
        }
        else if (MessageBoxMessage.Text == "")
        {
            if (hasPictureAttached == true)
            { SendButton.IsEnabled = true; }
            else
            { SendButton.IsEnabled = false; }
        }
        else
        {
            SendButton.IsEnabled = true;
        }

    }

    private void MessageBoxMessage_LostFocus(object sender, RoutedEventArgs e)
    {
        MessageBoxMessageHasFocus = false;

        if (MessageBoxMessage.Text == "")
        {                
            MessageBoxMessage.Text = "new message";

            if (hasPictureAttached == true)
            { SendButton.IsEnabled = true; }
            else
            { SendButton.IsEnabled = false; }
        }
        else if (MessageBoxMessage.Text == "new message")
        {                
            if (hasPictureAttached == true)
            { SendButton.IsEnabled = true; }
            else
            { SendButton.IsEnabled = false; }
        }
        else
        {
            SendButton.IsEnabled = true;
        }

    }

    int MessageBoxMessageTextChangedCounter = 0;
    private void MessageBoxMessage_TextChanged(object sender, TextChangedEventArgs e)
    {

        if (MessageBoxMessageTextChangedCounter == 0)
        {
            if ((MessageBoxMessage.Text != "" && MessageBoxMessage.Text != "new message") || hasPictureAttached == true)
            {
                SendButton.IsEnabled = true;
            }
            else { SendButton.IsEnabled = false; }

            MessageBoxMessageTextChangedCounter = 1;
            return;
        }
        else
        {
            MessageBoxMessageTextChangedCounter = 0;
        }

        if (MessageBoxMessage.Text != "" && MessageBoxMessage.Text != "new message")
        {
            MessageString = MessageBoxMessage.Text;
        }
    }


    private void SendButton_Click(object sender, EventArgs e)
    {
        if (MessageBoxMessage.Text == "new message" && hasPictureAttached == true)
        { MessageBoxMessage.Text = "";}


            SendButton.IsEnabled = false;
            if (hasPictureAttached == true)
            {
                //MessageString = MessageBoxMessage.Text;
                GetPictureUrl();
                hasPictureAttached = false;
            }
            else
            {
                //MessageString = MessageBoxMessage.Text;
                POSTmessage();
            }



        if (MessageBoxMessageHasFocus == true)
        {
            MessageBoxMessage.Text = "";
            MessageBoxMessage.SetValue(TextBox.TextProperty, "");
        }
        else
        {
            MessageBoxMessage.Text = "new message";
            MessageBoxMessage.SetValue(TextBox.TextProperty, "new message");
        }


    }

Below is the XAML

<TextBox x:Name="MessageBoxMessage" Margin="-12,0,-12,12" TextWrapping="Wrap" Foreground="Gray" TextChanged="MessageBoxMessage_TextChanged" LostFocus="MessageBoxMessage_LostFocus" GotFocus="MessageBoxMessage_GotFocus">
                        <TextBox.InputScope>
                            <InputScope>
                                <InputScopeName NameValue="Chat" />
                            </InputScope>
                        </TextBox.InputScope>
                    </TextBox>
  • 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-23T22:06:37+00:00Added an answer on May 23, 2026 at 10:06 pm

    After running the whole project…

    (thanks for supplying it complete via email. That made it much easier to debug)…

    There were a couple of issues with event handlers, but the actual cause of your Magic values is that each time you are navigating to the ConversationPage a new ConversationPage object is being created, but the previous one(s) has not been destroyed or reused.

    If you go away from the ConversationPage more than once you will actually hit your SendButton_Click once for every instance of the ConversationPage object ever created.

    The reason for that is your SendButton object is a singleton, shared across pages, so each page that connects to it gets its own click event. The existence of that link between the page and the static SendButton object means the Conversation page is never deleted (you have it on a leash!).

    You need to remove the SendButton handler in response the the OnNavigatedFrom page event like this:

    SendButton.Click -= SendButton_Click;
    

    That will remove the handler for the current page and allow it to die a graceful death.

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

Sidebar

Related Questions

I'm a beginner in MySql. But I am creating a calendar application, where I
I am a beginner creating a SEAM (2.2) application with JBoss AS6 I am
In a beginner's programming book (free licence) there was the following code, dynamically creating
I am creating my first site in asp.net MVC and I have a very
I'm a beginner in svn. I know basic things like creating a repository, checking,
I have a little problem that i'm creating a simple search application which have
Beginner level question Scenario: Have simple string cocantation tool, that I might expand later
Absolute beginner question: I have a template file index.html that looks like this: ...
Once again a very beginner-ish question, but here I go: I would like to
I am a beginner in xcode, I want to know how can I implement

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.