UWP : Need Close Button in CustomEditControl and Mouse Events to be Active..

Indudhar Gowda 426 Reputation points
2020-03-18T08:04:33.157+00:00

I have attached the project below..

  1. Need Close Button in the textbox
  2. Need Mouse Events or cursor postion to be active in the textbox.

https://1drv.ms/u/s!Ag8QU6ar3yRugYg7U-qDJ1o4VraieQ?e=8OnEqi

s!Ag8QU6ar3yRugYg7U-qDJ1o4VraieQ

4842-sdfsdf.gif

Universal Windows Platform (UWP)
Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,784 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Richard Zhang-MSFT 6,936 Reputation points
    2020-03-20T02:49:25.573+00:00

    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:

    1. Cancel all event monitoring on CoreWindow to avoid mutual interference between events.
    2. 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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.