Hello,
Welcome to our Microsoft Q&A platform!
I checked your project and the problem appeared on the CoreWindow_PointerPressed
method.
When you click the delete button, the button is not actually clicked. CoreWindow_PointerPressed
is like a layer of paper in the middle, blocking your pointer pressed operation.
It is not recommended to listen to the pointer pressed event of the entire Window for a control.
The purpose of your CoreWindow_PointerPressed
method is to determine whether the control should get focus when the pointer pressed, and change the state of the control. In fact, this does not need to listen to the PointerPressed
event, it only needs to listen to the CustomEditControl.GotFocus
and CustomEditControl.LostFocus
events.
So the suggestions for your problems are as follows:
- Cancel all event monitoring on
CoreWindow
to avoid mutual interference between events. - Handle the state of the control through Focus related events.
As for getting the cursor to the specified position by pointer pressed, this point needs to be analyzed according to the pointer pressed coordinates, and the StartCaretPosition
should be changed.
Nevertheless, I still recommend using the default TextBox
. The native controls have been tested many times and have integrated many functions. Modifying based on the native TextBox
control is easier than writing a TextBox control yourself.
Thanks.