问题
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">
回答1:
Ah the property TextWrapping="Wrap"
should be set to TextWrapping="NoWrap"
.
回答2:
Removing the TextWrapping property from the TextBox XAML worked for me.
来源:https://stackoverflow.com/questions/23383883/c-sharp-store-app-add-xbutton-at-the-end-of-a-textbox-or-searchbox