| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 | <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">    <ControlTemplate x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">        <Grid x:Name="grid">            <Grid.ColumnDefinitions>                <ColumnDefinition />                <ColumnDefinition Width="25" />            </Grid.ColumnDefinitions>            <Rectangle Grid.ColumnSpan="2" HorizontalAlignment="Stretch" x:Name="Rectangle" VerticalAlignment="Stretch" Width="Auto" Height="Auto" RadiusX="2" RadiusY="2" Fill="#f8f8f8" />            <!--<Border Margin="2,2,2,2" Grid.Column="1" Background="{StaticResource ThemeColor}" Width="20" Height="20" CornerRadius="3,3,3,3" x:Name="drop_border" />-->            <Path Grid.Column="1" HorizontalAlignment="Center" Width="Auto" x:Name="Arrow" VerticalAlignment="Center" Fill="{x:Null}" Data="M0.5,0.5 L3,6.5 5.5,0.5" Stroke="{StaticResource ThemeColor}" Margin="5,0,5,0" Height="7" StrokeThickness="2" Stretch="Fill" />        </Grid>    </ControlTemplate>        <ControlTemplate x:Key="ComboBoxTextBox" TargetType="{x:Type TextBox}">        <Border x:Name="PART_ContentHost" Focusable="False" Background="{TemplateBinding Background}" />    </ControlTemplate>        <Style TargetType="{x:Type ComboBox}">        <Setter Property="SnapsToDevicePixels" Value="true" />        <Setter Property="Template">            <Setter.Value>                <ControlTemplate TargetType="{x:Type ComboBox}">                    <Border BorderBrush="Orange" x:Name="border">                        <Grid x:Name="grid">                            <ToggleButton Template="{StaticResource ComboBoxToggleButton}" x:Name="ToggleButton" Focusable="false" IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press" />                            <ContentPresenter HorizontalAlignment="Left" Margin="5,0" x:Name="ContentSite" VerticalAlignment="Center" Content="{TemplateBinding SelectionBoxItem}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" IsHitTestVisible="False" />                            <TextBox Visibility="Hidden" Margin="2,2,22,2" x:Name="PART_EditableTextBox" Style="{x:Null}" VerticalAlignment="Center" Focusable="True" IsReadOnly="{TemplateBinding IsReadOnly}" Foreground="Black" HorizontalAlignment="Stretch" Background="{TemplateBinding Background}" />                            <!--文本输入框,当IsEditable为true 才显示-->                            <Popup IsOpen="{TemplateBinding IsDropDownOpen}" Placement="Bottom" x:Name="Popup" Focusable="False" AllowsTransparency="True" PopupAnimation="Slide">                                <Grid MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{TemplateBinding ActualWidth}" x:Name="DropDown" SnapsToDevicePixels="True">                                    <Border x:Name="DropDownBorder" Background="#f8f8f8" CornerRadius="3,3,3,3" />                                    <ScrollViewer  Margin="4,6,4,6" SnapsToDevicePixels="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" CanContentScroll="True" Foreground="{StaticResource {x:Static SystemColors.ActiveCaptionTextBrushKey}}">                                        <VirtualizingStackPanel  IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" />                                    </ScrollViewer>                                </Grid>                            </Popup>                        </Grid>                    </Border>                    <ControlTemplate.Triggers>                        <Trigger Property="HasItems" Value="false">                            <Setter Property="MinHeight" Value="95" TargetName="DropDownBorder" />                        </Trigger>                        <Trigger Property="IsGrouping" Value="true">                            <Setter Property="ScrollViewer.CanContentScroll" Value="false" />                        </Trigger>                        <Trigger Property="AllowsTransparency" SourceName="Popup" Value="true">                            <Setter Property="Margin" Value="0,2,0,0" TargetName="DropDownBorder" />                        </Trigger>                        <Trigger Property="IsEditable" Value="true">                            <Setter Property="IsTabStop" Value="false" />                            <Setter Property="Visibility" Value="Visible" TargetName="PART_EditableTextBox" />                            <Setter Property="Visibility" Value="Hidden" TargetName="ContentSite" />                        </Trigger>                    </ControlTemplate.Triggers>                </ControlTemplate>            </Setter.Value>        </Setter>    </Style></ResourceDictionary>
 |