当前位置:网站首页>win10 uwp 让焦点在点击在页面空白处时回到textbox中
win10 uwp 让焦点在点击在页面空白处时回到textbox中
2022-08-09 16:54:00 【林德熙】
在网上 有一个大神问我这样的问题:在做UWP的项目,怎么能让焦点在点击在页面空白处时回到textbox中? 虽然我的小伙伴认为他这是一个 xy 问题,但是我还是回答他这个问题。
首先需要知道什么是空白处,例如有下面的代码
<Grid><TextBox x:Name="XcjKfqnkor"></TextBox></Grid>那么空白就是 Grid ,需要点击他的时候回到 TextBox ,下面的代码我没有跑,可能无法运行
需要让 Grid 可以获得点击,需要给他背景
<Grid Background="#01FFFFFF"><TextBox x:Name="XcjKfqnkor"></TextBox></Grid>然后给 Grid 一个名称
<Grid x:Name="VkyZqfs" Background="#01FFFFFF"><TextBox x:Name="XcjKfqnkor"></TextBox></Grid>在后天代码添加按下空白地方让 XcjKfqnkor 获得焦点
Grid.AddHandler(PointerPressedEvent,
new PointerEventHandler(Grid_OnPointerPressed), true);
private void Grid_OnPointerPressed(object sender, PointerRoutedEventArgs e)
{
XcjKfqnkor.Focus();
}边栏推荐
- WPF效果第一百九十四篇之伸缩面板
- Jenkins使用pipeline部署服务到远程服务器
- International Soil Modeling Consortium-ISMC
- Experience far more than Hue, this is the favorite SQL tool for technicians
- win10 uwp 改变鼠标
- What you should know about futures account opening
- EPIC是什么平台?
- [ Kitex Source Code Interpretation ] Request to retry
- MySQL索引的B+树到底有多高?
- approach和method的区别
猜你喜欢
随机推荐
LINE Verda Programming Contest (AtCoder Beginner Contest 263) A~E 题解
One-key login principle of local number
win10 uwp 无法附加到CoreCLR
ABP详细教程——模块类
动态RDLC报表(四)
《.NET物联网从零开始》系列
神秘的程序员(20-30)
.NET静态代码织入——肉夹馍(Rougamo) 发布1.1.0
Logic unauthorized and horizontal and vertical unauthorized payment tampering, verification code bypass, interface
论文解读:Deep-4MCW2V:基于序列的预测指标,以鉴定大肠杆菌中的N4-甲基环胞嘧啶位点
有什么好的开源自动化测试框架可以推荐?
基于CAP组件实现补偿事务与幂等性保障
2022 全球 AI 模型周报
SkiaSharp 之 WPF 自绘 粒子花园(案例版)
试试使用 Vitest 进行组件测试,确实很香。
【Pycharm好用功能】
[Pycharm easy to use function]
自动生成设备节点
Self-taught software testing, how far can I go out to find a job?
体验远超Hue,这才是技术人员最喜欢的SQL工具








