[Junk Microsoft, what's missing] C # Metro app KeyDown issue

Source: Internet
Author: User

The following code is used to detect KeyDown event in a textbox:

        private void Txttest_keydown (object sender, Keyroutedeventargs e)
        {
            Lblinfo.text = Lblinfo.text + "," + (int) e.ke y;
        }


Try using keyboard reader to enter the card content to TextBox (at the end of enter), I thought I would display the letter or number of the card info in a TextBox (separated by commas), but actually only capture the last enter key , all of the previous keys were not captured. The reason, the original and the current keyboard input method. If the input method is Chinese, although the correct output in the TextBox card INFO, but KeyDown event will only capture the ENTER key, if the input method is in English, then you can capture all the keys.


It has nothing to do with keyboard reader because you can use virtual keyboard to enter information in a TextBox as well.


If it is not a textbox, but controls.page to trigger KeyDown event, because for the Chinese input method, the textbox does not capture the KeyDown event, but can obtain the card by obtaining the TextBox.Text Info If use Controls.page to trigger KeyDown event, then there must is at least one component in the page. PasswordBox or button component is recommended (it looks this no Chinese input issue for passwordbox and button), DON ' T us e textbox because of Chinese input issue.

Note:if no component in the ' page is focused ' (for example, your tap any other section in the page), then it'll not trigger a NY keydown Event!!! Hence the component lose focus, focus again.


Therefore, my solution of visitor Log Project Smart Reader view as below.

1. In the page, there are only one "Cancel" button except 2 labels. When the button is clicked, then back to parent page. If This button is lose focus and focus again.

2. It seems that your needn ' t set this button focused explicitly, if it's only one component in page, it'll be focuse D automatically when the page is loaded.

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.