<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
<!-- 定义 ComboBox 的样式 -->
|
<Style x:Key="ShowTextCombox" TargetType="ComboBox">
|
<Setter Property="IsEditable" Value="True"/>
|
<Setter Property="Template">
|
<Setter.Value>
|
<ControlTemplate TargetType="ComboBox">
|
<Grid>
|
<!-- 下拉按钮 -->
|
<ToggleButton x:Name="ToggleButton" Grid.Column="2" Focusable="false" ClickMode="Press"
|
FontSize="16"
|
HorizontalContentAlignment="Stretch"
|
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}">
|
<Grid>
|
<Grid.RowDefinitions>
|
<RowDefinition />
|
</Grid.RowDefinitions>
|
<Grid.ColumnDefinitions>
|
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="20"/>
|
</Grid.ColumnDefinitions>
|
<TextBlock Grid.Row="0" Grid.Column="0" Padding="3,1,0,1" TextAlignment="Left" Text="{TemplateBinding Text}" />
|
<Path Grid.Row="0" Grid.Column="1" Data="M 5,6 L 10,11 L 15,6" Stroke="Black" StrokeThickness="1"/>
|
</Grid>
|
</ToggleButton>
|
<!-- 弹出内容 -->
|
<Popup x:Name="Popup" IsOpen="{TemplateBinding IsDropDownOpen}" Placement="Bottom" Focusable="false" AllowsTransparency="True" PopupAnimation="Slide">
|
<Grid Name="DropDown" SnapsToDevicePixels="True" MinWidth="{TemplateBinding ActualWidth}" MaxHeight="{TemplateBinding MaxDropDownHeight}">
|
<Border x:Name="DropDownBorder" Background="White" BorderThickness="1" BorderBrush="Black"/>
|
<ScrollViewer SnapsToDevicePixels="True">
|
<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained"/>
|
</ScrollViewer>
|
</Grid>
|
</Popup>
|
</Grid>
|
<ControlTemplate.Triggers>
|
<Trigger Property="IsKeyboardFocusWithin" Value="True">
|
<Setter Property="IsDropDownOpen" Value="True"/>
|
</Trigger>
|
</ControlTemplate.Triggers>
|
</ControlTemplate>
|
</Setter.Value>
|
</Setter>
|
</Style>
|
</ResourceDictionary>
|