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. Is this possible?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
What you are seeing in Windows Explorer is a single-click on a selected/focused item initiating a rename operation. 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 (e.g. half a second) between the click on a selected/focused item and the UI going into rename mode. 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.
NOTE: The F2 key also tends to initiate rename operations on selected items if you want to wire that in as well.