Search code examples
c#wpfuser-controlstextbox

WPF textbox usercontrol containing custom items, not simple text


I'd like to have a custom usercontrol based on textbox where I could type in text (for example names) and the names would be then converted to custom items (that would have an X button to remove them, etc). This is what I would like:

alt text

How can I achieve this? Can I replace a piece of text with a custom item? Thanks for any ideas.


Solution

  • You can do this by changing the control template of the textbox. Since you are using a Usercontrol (and not creating a custom control), all you really need to do is remove the border of the textbox, add a Border around your usercontrol, and put the buttons + borderless textbox into a DockPanel or StackPanel.