problemas de plantilla de cuadro combinado wpf

I've created template for combobox but it has strange view, data is not displaying:

enter image description here

Aquí está el código XAML:

 <Style TargetType="{x:Type ComboBox}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type ComboBox}">
                <Border Background="{TemplateBinding Background}" x:Name="Bd" BorderBrush="Gray" BorderThickness="2" CornerRadius="2">
                </Border>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsEnabled" Value="False">
                        <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" TargetName="Bd"/>
                        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                    </Trigger>
                    <Trigger Property="IsFocused" Value="true">
                        <Setter Property="BorderBrush" Value="Blue" TargetName="Bd"/>
                        <Setter Property="BorderThickness" Value="2"/>
                    </Trigger>
                    <Trigger Property="IsFocused" Value="false">
                        <Setter Property="BorderBrush" Value="Gray" TargetName="Bd"/>
                        <Setter Property="BorderThickness" Value="2"/>
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>

    </Setter>
</Style>

What i missed here?

preguntado el 08 de noviembre de 11 a las 12:11

Timur, are you working on a read-only combo to display the lookup data? No element in your template is bound to the selected value of your combobox. You're gonna need a TextBox or a Lable somewhere bound to SelectedItem property. -

You've provided the style, but where is the combobox XAML itself with a content? -

I don't know how to add it)))) -

1 Respuestas

Your template creates near to nothing which makes the default one work, i.e. there is no items popup, and there is no ContentPresenter for the selected item either. Have a look at the default template and you will see exactly what you are missing (Aquí is a question explaining where to get them).

contestado el 23 de mayo de 17 a las 14:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.