简体   繁体   English

延迟双击以编辑文本块WPF

[英]Delayed double click for editing textblock WPF

I am trying to make it so a certain textblock turns editable with a delayed double click. 我试图让它成为一个特定的文本块变成可编辑的延迟双击。 Similar to the functionality in Windows Explorer when you do a delayed double click to edit file and folder names. 与延迟双击以编辑文件和文件夹名称时Windows资源管理器中的功能类似。 Is this possible? 这可能吗?

What you are seeing in Windows Explorer is a single-click on a selected/focused item initiating a rename operation. 您在Windows资源管理器中看到的是单击选定/聚焦项目以启动重命名操作。 The first click you're seeing actually selects/focuses the item and the second click initiates the rename operation. 您看到的第一次单击实际上选择/聚焦项目,第二次单击启动重命名操作。 You can verify this by using the keyboard to select a different item and then single-clicking on the newly selected item. 您可以使用键盘选择其他项目,然后单击新选择的项目来验证这一点。

It appears that there is a short duration (eg half a second) between the click on a selected/focused item and the UI going into rename mode. 似乎在所选/聚焦项目的点击与进入重命名模式的UI之间存在短持续时间(例如,半秒)。 So... if an item is clicked on which already has focus, you'll need to do something like starting a timer. 所以......如果点击已经有焦点的项目,你需要做一些像启动计时器的事情。 If that item still has focus when the timer expires, enter your renaming mode. 如果该项目在计时器到期时仍具有焦点,请输入您的重命名模式。

From there it is just a matter of applying the correct template with whichever trigger/flag logic you care to implement. 从那里开始,只需要使用您想要实现的触发器/标志逻辑来应用正确的模板。

EDIT : Do a search on WPF in-place editing and you should find some code examples. 编辑 :搜索WPF 就地编辑 ,你应该找到一些代码示例。

NOTE : The F2 key also tends to initiate rename operations on selected items if you want to wire that in as well. 注意 :如果您想要连接所选项目,F2键也倾向于启动对所选项目的重命名操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM