How to know when the 'x' button in TextBox was clicked?
I need to know when the text in TextBox
is cleared when clicking the 'x' button. There's no event for this in UWP or WinUI3.
Just the TextChanged
event does not help.
Solution 1:
1a: In Visual Studio 2019 and earlier, righclick on your project and click on "Design in Blend"
1b: In Visual Studio 2022 you can directly righlick on "View" and there under "Other Windows" you can open the Document Outline
2a: After Blend is opened, you go to "Objects and Timeline" and rightclick on your Textbox, which shows up in the list. In the rightclick menu you go to "Edit template" and from there to "Edit a copy".
2b Under Document Outline you can also righlick on your Textbox and then on "Edit template" and from there to "Edit a Copy"
3: A little window pops up and in it you can enter the name of the style.
4: Visual Studio will now create a custom style for your Textbox.
5: In your customstyle-code locate the button named "DeleteButton" and add your Click event to it.
Thats it.