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