|
39 | 39 | </Trigger> |
40 | 40 | </Style.Triggers> |
41 | 41 | </Style> |
| 42 | + |
| 43 | + <ControlTemplate x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}"> |
| 44 | + <Grid> |
| 45 | + <Grid.ColumnDefinitions> |
| 46 | + <ColumnDefinition /> |
| 47 | + <ColumnDefinition Width="20" /> |
| 48 | + </Grid.ColumnDefinitions> |
| 49 | + <Border x:Name="Border" Grid.ColumnSpan="2" CornerRadius="0" Background="{DynamicResource {x:Static common:ColorTheme.Background}}" BorderBrush="{DynamicResource {x:Static common:ColorTheme.Foreground}}" BorderThickness="1" /> |
| 50 | + <Border Grid.Column="0" CornerRadius="0" Margin="1" Background="{DynamicResource {x:Static common:ColorTheme.Background}}" BorderThickness="0" /> |
| 51 | + <Path x:Name="Arrow" Grid.Column="1" Fill="{DynamicResource {x:Static common:ColorTheme.Foreground}}" HorizontalAlignment="Center" VerticalAlignment="Center" Data="M4,4 L0,0 L0,2 L4,6 L8,2 L8,0 z" /> |
| 52 | + </Grid> |
| 53 | + </ControlTemplate> |
| 54 | + |
| 55 | + <Style x:Key="{x:Type ComboBox}" TargetType="{x:Type ComboBox}"> |
| 56 | + <Setter Property="FocusVisualStyle" Value="{x:Null}"/> |
| 57 | + <Setter Property="SnapsToDevicePixels" Value="true"/> |
| 58 | + <Setter Property="OverridesDefaultStyle" Value="true"/> |
| 59 | + <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/> |
| 60 | + <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/> |
| 61 | + <Setter Property="ScrollViewer.CanContentScroll" Value="true"/> |
| 62 | + <Setter Property="Foreground" Value="{DynamicResource {x:Static common:ColorTheme.Foreground}}"/> |
| 63 | + <Setter Property="Template"> |
| 64 | + <Setter.Value> |
| 65 | + <ControlTemplate TargetType="{x:Type ComboBox}"> |
| 66 | + <Grid> |
| 67 | + <ToggleButton Name="ToggleButton" Template="{StaticResource ComboBoxToggleButton}" Grid.Column="2" Focusable="false" IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press"/> |
| 68 | + <ContentPresenter Name="ContentSite" IsHitTestVisible="False" Content="{TemplateBinding SelectionBoxItem}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" Margin="3,3,23,3" VerticalAlignment="Center" HorizontalAlignment="Left" /> |
| 69 | + <Popup Name="Popup" Placement="Bottom" IsOpen="{TemplateBinding IsDropDownOpen}" AllowsTransparency="True" Focusable="False" PopupAnimation="Slide"> |
| 70 | + <Grid Name="DropDown" SnapsToDevicePixels="True" MinWidth="{TemplateBinding ActualWidth}" MaxHeight="{TemplateBinding MaxDropDownHeight}"> |
| 71 | + <Border x:Name="DropDownBorder" Background="{DynamicResource {x:Static common:ColorTheme.Background}}" BorderThickness="1" BorderBrush="{DynamicResource {x:Static common:ColorTheme.Foreground}}"/> |
| 72 | + <ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True"> |
| 73 | + <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" /> |
| 74 | + </ScrollViewer> |
| 75 | + </Grid> |
| 76 | + </Popup> |
| 77 | + </Grid> |
| 78 | + <ControlTemplate.Triggers> |
| 79 | + <Trigger Property="HasItems" Value="false"> |
| 80 | + <Setter TargetName="DropDownBorder" Property="MinHeight" Value="95"/> |
| 81 | + </Trigger> |
| 82 | + <Trigger Property="IsEnabled" Value="false"> |
| 83 | + <Setter Property="Foreground" Value="#888888"/> |
| 84 | + </Trigger> |
| 85 | + <Trigger Property="IsGrouping" Value="true"> |
| 86 | + <Setter Property="ScrollViewer.CanContentScroll" Value="false"/> |
| 87 | + </Trigger> |
| 88 | + <Trigger SourceName="Popup" Property="Popup.AllowsTransparency" Value="true"> |
| 89 | + <Setter TargetName="DropDownBorder" Property="CornerRadius" Value="0"/> |
| 90 | + <Setter TargetName="DropDownBorder" Property="Margin" Value="0,2,0,0"/> |
| 91 | + </Trigger> |
| 92 | + <Trigger Property="IsEditable" Value="true"> |
| 93 | + <Setter Property="IsTabStop" Value="false"/> |
| 94 | + <Setter TargetName="ContentSite" Property="Visibility" Value="Hidden"/> |
| 95 | + </Trigger> |
| 96 | + </ControlTemplate.Triggers> |
| 97 | + </ControlTemplate> |
| 98 | + </Setter.Value> |
| 99 | + </Setter> |
| 100 | + <Style.Triggers> |
| 101 | + </Style.Triggers> |
| 102 | + </Style> |
| 103 | + |
| 104 | + <Style x:Key="{x:Type ComboBoxItem}" TargetType="{x:Type ComboBoxItem}"> |
| 105 | + <Setter Property="SnapsToDevicePixels" Value="true"/> |
| 106 | + <Setter Property="Foreground" Value="{DynamicResource {x:Static common:ColorTheme.Foreground}}"/> |
| 107 | + <Setter Property="OverridesDefaultStyle" Value="true"/> |
| 108 | + <Setter Property="Template"> |
| 109 | + <Setter.Value> |
| 110 | + <ControlTemplate TargetType="{x:Type ComboBoxItem}"> |
| 111 | + <Border Name="Border" Padding="2" SnapsToDevicePixels="true"> |
| 112 | + <ContentPresenter /> |
| 113 | + </Border> |
| 114 | + <ControlTemplate.Triggers> |
| 115 | + <Trigger Property="IsHighlighted" Value="true"> |
| 116 | + <Setter TargetName="Border" Property="Background" Value="{DynamicResource {x:Static common:ColorTheme.ComboBox_MouseOverBackground}}"/> |
| 117 | + <Setter Property="Foreground" Value="{DynamicResource {x:Static common:ColorTheme.ComboBox_MouseOverForeground}}" /> |
| 118 | + </Trigger> |
| 119 | + <Trigger Property="IsEnabled" Value="false"> |
| 120 | + <Setter Property="Foreground" Value="#888888"/> |
| 121 | + </Trigger> |
| 122 | + </ControlTemplate.Triggers> |
| 123 | + </ControlTemplate> |
| 124 | + </Setter.Value> |
| 125 | + </Setter> |
| 126 | + </Style> |
42 | 127 | </UserControl.Resources> |
43 | 128 |
|
44 | 129 | <Grid> |
|
0 commit comments