Click in the TextBox Part of the ComboBox

We have a style for the ComboBox:

<Style x:Key="OurComboBox" TargetType="ComboBox">
    <!-- omitted style Properties -->
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ComboBox">
                    <Grid>
                        <ToggleButton Name="ToggleButton"
                                      Grid.Column="2"
                                      ClickMode="Press"
                                      Focusable="false"
                                      IsChecked="{Binding Path=IsDropDownOpen,
                                                          Mode=TwoWay,
                                                          RelativeSource={RelativeSource TemplatedParent}}"
                                      Style="{StaticResource ComboBoxToggleButton}" />
                        <ContentPresenter Name="ContentSite"
                                          Margin="3,3,23,3"
                                          HorizontalAlignment="Left"
                                          VerticalAlignment="Center"
                                          Content="{TemplateBinding SelectionBoxItem}"
                                          ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
                                          ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                                          IsHitTestVisible="False" />
                        <TextBox x:Name="PART_EditableTextBox"
                                 Margin="5,3,23,1"
                                 HorizontalAlignment="Left"
                                 VerticalAlignment="Center"
                                 Background="Transparent"
                                 Focusable="False"
                                 FontFamily="Arial Narrow"
                                 FontWeight="DemiBold"
                                 Foreground="#FF404040"
                                 IsReadOnly="True"
                                 PreviewMouseDown=""
                                 Style="{x:Null}"
                                 Template="{StaticResource ComboBoxTextBox}"
                                 Text="{TemplateBinding Text}"
                                 Visibility="Hidden" />

            <!-- omitted PopUp and ControlTemplate.Triggers -->

      

And based on this, we have another more specific style

 <Style x:Key="comboBoxSpecialPage"
           BasedOn="{StaticResource OurComboBox}"
           TargetType="ComboBox">
        <Style.Triggers>
            <Trigger Property="SelectedIndex" Value="-1">
                <Setter Property="Text" Value="Select value" />
            </Trigger>
        </Style.Triggers>
    </Style>

      

Which results in the text "Select a value" if nothing is selected in the ComboBox, eg. when starting the application.

But when I click directly on the TextBox, nothing happens.

So the question is: How to get the PopUp open, how and when the rest of the ComboBox is called (part without text)?

-edit- If I missed interesting parts, please let me know, I will add them.

+3


source to share


2 answers


Perhaps the IsHitTestVisible property is what you are looking for, more information here: Text tag and IsHitTestVisible property



+2


source


The ComboBox has a DropDownStyle property. Set this to DropDownList and the text area is no longer editable, i.e. You need to choose from the list.



0


source







All Articles