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

為{幸葍}努か 提交于 2019-12-25 03:11:04

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!