Have a texbox with "tag" like behavior in wpf? -


lets have textbox control user can type in, want textbox control behave similiar "tags" textbox appears right below, type in textbox, show list of suggestions, when user selects suggestion pop in textbox , display small button.

i have wired textbox, listbox showing in popup suggestions , go selection of suggestions working, strugglinh making button appear , dissapear when user backspaces etc.

requirements: need have 1 tag.

problems: want button inside texbox, appears outside right now.

do guys have suggestions?

my xaml:

        <grid>                             <grid.columndefinitions>                                 <columndefinition width="30"></columndefinition>                                 <columndefinition width="*"></columndefinition>                                 <columndefinition width="8"></columndefinition>                                 <columndefinition width="auto"></columndefinition>                             </grid.columndefinitions>                             <button content="res" grid.column="0" width="30" x:name="tagbutton" /> <!-- tag button want collapse show. -->                             <textbox x:name="searchtextbox"                                       grid.column="1"                                      previewkeydown="searchtextbox_previewkeydown"                                      keyup="searchtextbox_keyup"                                       margin="0,2,0,0" fontsize="14"                                       padding="3"                                       text="{binding elementname=root, path=searchtext, updatesourcetrigger=propertychanged, delay=100}">                                                         </textbox>  <popup x:name="suggestionpopup"                placementtarget="{binding elementname=outerborder}"                 placement="bottom"                                isopen="false"                staysopen="false"                allowstransparency="true"                margin="0,23,0,0">            <mylistboxhere>         </popup>      </grid> 

if want button appear inside textbox control, need override control template textbox create custom control allow that. standard textbox control accept string (or numeric values) content.

you can make button inside textbox like:

    <border width="120" height="35"             borderbrush="black" borderthickness="1">         <stackpanel orientation="horizontal">             <textbox width="70" borderbrush="transparent"/>             <button content="mytag" margin="4"/>         </stackpanel>     </border> 

enter image description here

you can change styling on textbox borderless , same color border object, , button inside textbox. border control becomes new outline of "textbox".


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -