Search code examples
c#xamlwindows-store-apps

C# store app. Add "X"button at the end of a textbox or searchbox


I have a C# store app where I have a search box or a textbox. I noticed that when I enter text in either the text or searchbox I don't get the "X" button at the end of the box to clear the text.

In this example there is someone with a similar problem: Remove "X" button at the end of a TextBox But I want to reverse that action.

As I understand in the above link, the button should appear automatically, but it does not. Does anyone know how I can get that "X" button to appear on either a searchbox or textbox?

the boxes:

<TextBox
    x:Name="textboxNoX"
    Grid.Column="1"
    HorizontalAlignment="Left"
    Margin="401,66,0,0"
    TextWrapping="Wrap"
    Text=""
    VerticalAlignment="Top"
    Width="259"/>

<SearchBox
    x:Name="searchbarNoX"
    Grid.Column="1"
    HorizontalAlignment="Left"
    Margin="400.998,33.478,0,0"
    VerticalAlignment="Top"
    RenderTransformOrigin="0.5,0.5"
    UseLayoutRounding="False"
    Width="256.565"
    d:LayoutRounding="Auto">

Solution

  • Ah the property TextWrapping="Wrap" should be set to TextWrapping="NoWrap".