tags:

views:

1308

answers:

5

I'd like to make a textbox with a button inside, something like a date picker, but not exactly. Or it can be a combobox inside the textbox, so you can switch the text box "mode".

Can you help me?

A: 

You can use RichTextBox instead of textbox and it support flowdocument in which you can place the button in it.

Firoz
+3  A: 

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 at http://msdn.microsoft.com/en-us/library/ms752094.aspx

Nir
I actually chose this way in the end. I used Border element to emulate the text box outer border and put the real border-less textbox and a button inside using Grid.
Yacoder
+1 for the link to the Combobox template.
Dan Puzey
A: 

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.

Jalfp
A: 

I created a textbox control and added this It seems to work, but not the ideal situation cos it recreates another textbox.

<TextBox.Template>
 <ControlTemplate>
        <Grid>
            <Grid.ColumnDefinitions></Grid.ColumnDefinitions>
            <TextBox Grid.Column="0"></TextBox>
            <Button HorizontalAlignment="Right" Width="25" Grid.Column="1">
            </Button>
        </Grid>         
    </ControlTemplate>
</TextBox.Template>
Tim