Search code examples
c#xamlwindows-8windows-runtimewindows-store-apps

Remove "X" button at the end of a TextBox


enter image description here

I'm developing a Windows Store App using C# + XAML. When I add a TextBox with the property TextWrapping set to NoWrap, a "X" appears at the end of the TextBox when it's focused.

So, I need to remove this "X" and the TextBox can not Wrap.


Solution

  • As you can see from this documentation it explains the feature quite well. As you can see when utilizing Javascript, Html, or Css you have very quick concise ways to remove that field. As you can simply disable it with Cascading Stylesheets.

    Image it displays. To Edit.

    Now within a Stylesheet you can actually alter it quite easy:

    input[type=text]::-ms-clear
    {
                border: 2px solid orange
    }
    

    Most of the buttons are really easy to utilize for a consistent design within your application. But that doesn't answer your question, how do you disable it with C#/XAML?

    Inside of the Textbox Component you'll notice code that indicates Visual State and Visibility. If you comment out that section of code it will disable the X. An example here:

    As mentioned above though, it is a very nifty and useful tool. Especially on touch screen devices; not only does it adhere to Microsofts unification but it also makes the UI cleaner as you have a simple way to delete the items in that field.

    I'd urge you not to remove it, hopefully this explains the issue a little bit for you.