Note the bug of developing phonetextbox in Windows Phone 7 (WP7)

Source: Internet
Author: User

The phonetextbox control, one of the Toolkit controls, is a little thing that I like very much about. The reason is very simple. It comes with a default prompt. When the user does not enter it, the text value is string. empty, this prompt will appear, and the color is very light, and when the user enters any content, the prompt will be hidden, this operation method is suitable for devices with small screen sizes such as mobile phones. It is much more comfortable than that of textblock and textbox.

However, a problem was found in the test two days ago. A phonetextbox in the application is used to display the geographical location of the user. When GPS works properly, by default, its text value is bound to the address resolved after GPS obtains the coordinates. If GPS is abnormal, the hint value displays "GPS exception, enter your current address manually ". This setting is still normal, isn't it.

But the problem arises. Specific recurrence: Before starting the application, close the GPS in the settings of the mobile phone and start the application. phonetextbox prompts "GPS exception, please manually enter your current address ", Press start to return to the home page, then go to the mobile phone settings to enable GPS, and then continuously press the back key to return to the application just now, my GPS data was obtained once in the loaded event, and then I had to manually refresh the data. Obviously, GPS was not automatically refreshed at this time, then I enter the page with a manual button to refresh (not in the same page as phonetextbox) and manually refresh the GPS coordinates. After the GPS coordinates and positions are properly resolved, press the back key to return the home page with phonetextbox. In this case, the problem occurs: the string indicated by the hint and the geographical location displayed by the text appear in the phonetextbox, the two strings are overlapped here, which is uncomfortable.

This is a bug. In simple analysis, the text value of phonetextbox is bound in two directions. After the GPS data is refreshed on another page, the text value of phonetextbox is changed accordingly, however, because the phonetextbox page is not activated, the hint of phonetextbox does not disappear.

After finding this problem, I tried to manually monitor the text changes in phonetextbox and then control the hiding of hint, but I found this is not a good solution. Later, we bound the default geographic location obtained by GPS to the hint and made a converter as follows:

Public class nowaddressconverter: ivalueconverter {public object convert (object value, type targettype, object parameter, system. globalization. cultureinfo culture) {string result = value. tostring (); If (result = "") {return "GPS exception, enter your current address manually";} else {string STR = @ "Current address :"; if (value. tostring (). startswith (STR) Result = value. tostring (); else {result = STR + value;} return result;} public object convertback (object value, type targettype, object parameter, system. globalization. cultureinfo culture) {return "";}}

In this way, the GPS data and default prompts are put in the hint attribute, so as to bypass the bug mentioned above. This is only a temporary solution.

(Note: The toolkit I currently use is the latest version in 2011.11, Which is downloaded by nuget)

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.