Win10 UWP lets focus go back to the textbox when clicked on a blank page

Source: Internet
Author: User
Tags creative commons attribution blank page

Original: Win10 UWP lets focus go back to the textbox when clicked on a blank page

There is a big God on the Internet asking me this question: how can I get the focus back to the textbox when I click on the blank page of the UWP project?

Although my little friend thought he was an xy question, I answered the question.

The first thing you need to know is where the blanks are, such as the following code

 <Grid><TextBox x:Name="XcjKfqnkor"></TextBox></Grid>

Then the blank is the Grid, need to click on his time back to the TextBox, the following code I did not run, may not run

Need to get the Grid to get clicked and need to give him background

 <Grid Background="#01FFFFFF"><TextBox x:Name="XcjKfqnkor"></TextBox></Grid>

Then give the Grid a name

 <Grid x:Name="VkyZqfs" Background="#01FFFFFF"><TextBox x:Name="XcjKfqnkor"></TextBox></Grid>

In the acquired code add press blank place let Xcjkfqnkor get focus

Grid.AddHandler(PointerPressedEvent,                new PointerEventHandler(Grid_OnPointerPressed), true);         private void Grid_OnPointerPressed(object sender, PointerRoutedEventArgs e)        {            XcjKfqnkor.Focus();        }

See also: win10 UWP get button mouse left click-Lindesi

UWP Development Pit---Routed events-happy on your heart's blog

If it is a technical problem, it is suggested to StackOverflow to ask questions in csdn to ask for a moment less than to see the great God watching

Welcome to Q Group 53078485 discussion UWP


This work is licensed under the Creative Commons Attribution-NonCommercial use-Share 4.0 International license agreement in the same way. Welcome to reprint, use, republish, but be sure to keep the article Attribution Lindesi (including Link: http://blog.csdn.net/lindexi_gd), not for commercial purposes, based on the modified works of this article must be issued with the same license. If you have any questions, please contact me.

Win10 UWP lets focus go back to the textbox when clicked on a blank page

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.