<ResourceDictionary
    xmlns="https://github.com/avaloniaui"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:CompileBindings="True">
    <Design.PreviewWith>
        <StackPanel Margin="20" Spacing="20">
            <TextBox Text="Hello" />
            <AutoCompleteBox Width="100" />
        </StackPanel>
    </Design.PreviewWith>
    <ControlTheme x:Key="{x:Type AutoCompleteBox}" TargetType="AutoCompleteBox">
        <Setter Property="AutoCompleteBox.MaxDropDownHeight" Value="{DynamicResource AutoCompleteMaxDropdownHeight}" />
        <Setter Property="Template">
            <ControlTemplate TargetType="AutoCompleteBox">
                <DataValidationErrors>
                    <Panel>
                        <TextBox
                            Name="PART_TextBox"
                            VerticalAlignment="Center"
                            DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}"
                            Theme="{DynamicResource NonErrorTextBox}"
                            Watermark="{TemplateBinding Watermark}" />
                        <Popup
                            Name="PART_Popup"
                            MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}"
                            MaxHeight="{TemplateBinding MaxDropDownHeight}"
                            IsLightDismissEnabled="True"
                            PlacementTarget="{TemplateBinding}">
                            <Border
                                Margin="{DynamicResource AutoCompleteBoxPopupMargin}"
                                HorizontalAlignment="Stretch"
                                Background="{DynamicResource AutoCompleteBoxPopupBackground}"
                                BorderBrush="{DynamicResource AutoCompleteBoxPopupBorderBrush}"
                                BorderThickness="{DynamicResource AutoCompleteBoxPopupBorderThickness}"
                                BoxShadow="{DynamicResource AutoCompleteBoxPopupBoxShadow}"
                                CornerRadius="{DynamicResource AutoCompleteBoxPopupCornerRadius}">
                                <ListBox
                                    Name="PART_SelectingItemsControl"
                                    Foreground="{TemplateBinding Foreground}"
                                    ItemTemplate="{TemplateBinding ItemTemplate}"
                                    ScrollViewer.HorizontalScrollBarVisibility="Auto"
                                    ScrollViewer.VerticalScrollBarVisibility="Auto" />
                            </Border>
                        </Popup>
                    </Panel>
                </DataValidationErrors>
            </ControlTemplate>
        </Setter>

        <Style Selector="^.Bordered">
            <Setter Property="Template">
                <ControlTemplate TargetType="AutoCompleteBox">
                    <Panel>
                        <TextBox
                            Name="PART_TextBox"
                            VerticalAlignment="Center"
                            Classes="Bordered"
                            DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}"
                            Watermark="{TemplateBinding Watermark}" />
                        <Popup
                            Name="PART_Popup"
                            MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}"
                            MaxHeight="{TemplateBinding MaxDropDownHeight}"
                            IsLightDismissEnabled="True"
                            PlacementTarget="{TemplateBinding}">
                            <Border
                                Margin="{DynamicResource AutoCompleteBoxPopupMargin}"
                                HorizontalAlignment="Stretch"
                                Background="{DynamicResource AutoCompleteBoxPopupBackground}"
                                BorderBrush="{DynamicResource AutoCompleteBoxPopupBorderBrush}"
                                BorderThickness="{DynamicResource AutoCompleteBoxPopupBorderThickness}"
                                BoxShadow="{DynamicResource AutoCompleteBoxPopupBoxShadow}"
                                CornerRadius="{DynamicResource AutoCompleteBoxPopupCornerRadius}">
                                <ListBox
                                    Name="PART_SelectingItemsControl"
                                    Foreground="{TemplateBinding Foreground}"
                                    ItemTemplate="{TemplateBinding ItemTemplate}"
                                    ScrollViewer.HorizontalScrollBarVisibility="Auto"
                                    ScrollViewer.VerticalScrollBarVisibility="Auto" />
                            </Border>
                        </Popup>
                    </Panel>
                </ControlTemplate>
            </Setter>
        </Style>
        <Style Selector="^.Large /template/ TextBox">
            <Setter Property="MinHeight" Value="{DynamicResource AutoCompleteBoxLargeHeight}" />
        </Style>
        <Style Selector="^.Small /template/ TextBox">
            <Setter Property="MinHeight" Value="{DynamicResource AutoCompleteBoxSmallHeight}" />
        </Style>
    </ControlTheme>




</ResourceDictionary>
