Search code examples
wpfxaml

WPF - Templated Combobox's drop down won't open


I have a very simple ControlTemplate for a control based off a combobox (I call it AutoComplete):

<ControlTemplate x:Key="AutoCompleteControlTemplate" TargetType="{x:Type ctr:AutoComplete}">
    <Grid>
        <TextBox x:Name="PART_EditableTextBox" Template="{StaticResource TextBoxBaseControlTemplate}" FontSize="30" FontFamily="Calibri" />
    </Grid>
</ControlTemplate>

Whenever I apply this template to the control, the combobox's drop down refuses to open. Am I missing something?


Solution

  • Since the drop down is contained in the original ControlTemplate of the control - which you overwrite - it is simply not there any more. Either try accomplishing what you want without overwriting the ControlTemplate, or build your own drop down.

    Some hints: The ComboBox has a property IsEditable, which makes it so that you can write text into it. If you want to build your own drop down, look at the Popup control.