I'd like to make a TextBox
with a Button
inside, something like a DatePicker
, but not exactly. Or can it be a ComboBox
inside the TextBox
, so you can switch the mode of the TextBox
.
Can you help me?
I'd like to make a TextBox
with a Button
inside, something like a DatePicker
, but not exactly. Or can it be a ComboBox
inside the TextBox
, so you can switch the mode of the TextBox
.
Can you help me?
You may find this link helps: http://msdn.microsoft.com/en-us/library/ms752068(VS.85).aspx.
"The ControlTemplate for a TextBox must contain exactly one element that is tagged as the content host element; this element will be used to render the contents of the TextBox. To tag an element as the content host, assign it the special name PART_ContentHost. The content host element must be either a ScrollViewer or an AdornerDecorator. The content host element may not host any child elements."
You can use RichTextBox instead of textbox and it support flowdocument in which you can place the button in it.
You may use a grid to accomplish this task. The following is how I created a button which appears at the right bottom of a TextBox:
If you want something like a combobox or a date time picker you should create a new control, inside this new control place a text box and a button side by side inside a frame that looks like the frame of a textbox - then restyle the textbox so it doesn't have a frame.
putting a button inside a rich edit is great if you want to put a button inside a "document" but not a good substitute for a combobox.
See the ComboBox control template MSDN
Just use Grid.Column same like below code
You can also use a Label and change its template to include a Button in it. To have a good overview of differences between Label and TextBlock see this post.