committed by
GitHub
10 changed files with 585 additions and 64 deletions
@ -1,64 +1,192 @@ |
|||||
<Styles xmlns="https://github.com/avaloniaui"> |
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
||||
|
<Design.PreviewWith> |
||||
|
<Border Padding="20"> |
||||
|
<StackPanel Spacing="10"> |
||||
|
<ComboBox PlaceholderText="Select an item"> |
||||
|
<ComboBoxItem>Item 1</ComboBoxItem> |
||||
|
<ComboBoxItem>Item 2</ComboBoxItem> |
||||
|
</ComboBox> |
||||
|
|
||||
|
<ComboBox IsEnabled="False"> |
||||
|
<ComboBoxItem>Item 1</ComboBoxItem> |
||||
|
<ComboBoxItem>Item 2</ComboBoxItem> |
||||
|
</ComboBox> |
||||
|
</StackPanel> |
||||
|
</Border> |
||||
|
</Design.PreviewWith> |
||||
|
<Styles.Resources> |
||||
|
<Thickness x:Key="ComboBoxTopHeaderMargin">0,0,0,4</Thickness> |
||||
|
<x:Int32 x:Key="ComboBoxPopupMaxNumberOfItems">15</x:Int32> |
||||
|
<x:Int32 x:Key="ComboBoxPopupMaxNumberOfItemsThatCanBeShownOnOneSide">7</x:Int32> |
||||
|
|
||||
|
<Thickness x:Key="ComboBoxPadding">12,5,0,7</Thickness> |
||||
|
<Thickness x:Key="ComboBoxEditableTextPadding">11,5,32,6</Thickness> |
||||
|
<Thickness x:Key="ComboBoxMinHeight">32</Thickness> |
||||
|
</Styles.Resources> |
||||
<Style Selector="ComboBox"> |
<Style Selector="ComboBox"> |
||||
<Setter Property="Background" Value="Transparent"/> |
<Setter Property="Padding" Value="{DynamicResource ComboBoxPadding}" /> |
||||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/> |
<Setter Property="MaxDropDownHeight" Value="504" /> |
||||
<Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}"/> |
<Setter Property="Foreground" Value="{DynamicResource ComboBoxForeground}" /> |
||||
<Setter Property="Padding" Value="4"/> |
<Setter Property="Background" Value="{DynamicResource ComboBoxBackground}" /> |
||||
<Setter Property="MinHeight" Value="20"/> |
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxBorderBrush}" /> |
||||
|
<Setter Property="BorderThickness" Value="{DynamicResource ComboBoxBorderThemeThickness}" /> |
||||
|
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" /> |
||||
|
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" /> |
||||
|
<Setter Property="HorizontalAlignment" Value="Left" /> |
||||
|
<Setter Property="VerticalAlignment" Value="Top" /> |
||||
|
<Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" /> |
||||
|
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" /> |
||||
|
<Setter Property="PlaceholderForeground" Value="{DynamicResource ComboBoxPlaceHolderForeground}" /> |
||||
<Setter Property="Template"> |
<Setter Property="Template"> |
||||
<ControlTemplate> |
<ControlTemplate> |
||||
<Border Name="border" |
<Grid RowDefinitions="Auto, *, Auto" ColumnDefinitions="*,32"> |
||||
Background="{TemplateBinding Background}" |
<ContentPresenter x:Name="HeaderContentPresenter" |
||||
BorderBrush="{TemplateBinding BorderBrush}" |
Grid.Row="0" |
||||
BorderThickness="{TemplateBinding BorderThickness}"> |
Grid.Column="0" |
||||
<Grid ColumnDefinitions="*,Auto"> |
Grid.ColumnSpan="2" |
||||
<ContentControl Content="{TemplateBinding SelectionBoxItem}" |
TextBlock.FontWeight="{DynamicResource ComboBoxHeaderThemeFontWeight}" |
||||
ContentTemplate="{TemplateBinding ItemTemplate}" |
Margin="{DynamicResource ComboBoxTopHeaderMargin}" |
||||
Margin="{TemplateBinding Padding}" |
VerticalAlignment="Top" /> |
||||
HorizontalAlignment="Left" |
<Border x:Name="Background" |
||||
VerticalAlignment="Center"/> |
Grid.Row="1" |
||||
<ToggleButton Name="toggle" |
Grid.Column="0" |
||||
BorderThickness="0" |
Grid.ColumnSpan="2" |
||||
|
Background="{TemplateBinding Background}" |
||||
|
BorderBrush="{TemplateBinding BorderBrush}" |
||||
|
BorderThickness="{TemplateBinding BorderThickness}" |
||||
|
CornerRadius="{DynamicResource ControlCornerRadius}" |
||||
|
MinWidth="{DynamicResource ComboBoxThemeMinWidth}" /> |
||||
|
|
||||
|
<Border x:Name="HighlightBackground" |
||||
|
Grid.Row="1" |
||||
|
Grid.Column="0" |
||||
|
Grid.ColumnSpan="2" |
||||
|
Background="{DynamicResource ComboBoxBackgroundUnfocused}" |
||||
|
BorderBrush="{DynamicResource ComboBoxBackgroundBorderBrushUnfocused}" |
||||
|
BorderThickness="{TemplateBinding BorderThickness}" |
||||
|
CornerRadius="{DynamicResource ControlCornerRadius}" |
||||
|
Opacity="0" /> |
||||
|
<TextBlock x:Name="PlaceholderTextBlock" |
||||
|
Grid.Row="1" |
||||
|
Grid.Column="0" |
||||
|
HorizontalAlignment="Left" |
||||
|
VerticalAlignment="Center" |
||||
|
Margin="{TemplateBinding Padding}" |
||||
|
Foreground="{TemplateBinding PlaceholderForeground}" |
||||
|
Text="{TemplateBinding PlaceholderText}" IsVisible="{TemplateBinding SelectionBoxItem, Converter={x:Static ObjectConverters.IsNull}}"/> |
||||
|
<ContentControl x:Name="ContentPresenter" |
||||
|
Content="{TemplateBinding SelectionBoxItem}" |
||||
|
ContentTemplate="{TemplateBinding ItemTemplate}" |
||||
|
Grid.Row="1" |
||||
|
Grid.Column="0" |
||||
|
Margin="{TemplateBinding Padding}" |
||||
|
HorizontalAlignment="Left" |
||||
|
VerticalAlignment="Center"> |
||||
|
</ContentControl> |
||||
|
|
||||
|
<Border x:Name="DropDownOverlay" |
||||
|
Grid.Row="1" |
||||
|
Grid.Column="1" |
||||
Background="Transparent" |
Background="Transparent" |
||||
ClickMode="Press" |
Margin="0,1,1,1" |
||||
Focusable="False" |
Width="30" IsVisible="False" |
||||
IsChecked="{TemplateBinding IsDropDownOpen, Mode=TwoWay}" |
HorizontalAlignment="Right" /> |
||||
Grid.Column="1"> |
|
||||
<Path Fill="{DynamicResource ThemeForegroundBrush}" |
<Viewbox UseLayoutRounding="False" |
||||
Width="8" |
MinHeight="{DynamicResource ComboBoxMinHeight}" |
||||
Height="4" |
Grid.Row="1" |
||||
Stretch="Uniform" |
Grid.Column="1" |
||||
HorizontalAlignment="Center" |
IsHitTestVisible="False" |
||||
VerticalAlignment="Center" |
Margin="0,0,10,0" Height="12" Width="12" |
||||
Data="F1 M 301.14,-189.041L 311.57,-189.041L 306.355,-182.942L 301.14,-189.041 Z"/> |
HorizontalAlignment="Right" |
||||
</ToggleButton> |
VerticalAlignment="Center"> |
||||
<Popup Name="PART_Popup" |
<Panel> |
||||
IsOpen="{TemplateBinding IsDropDownOpen, Mode=TwoWay}" |
<Panel Height="12" Width="12" /> |
||||
MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}" |
<Path x:Name="DropDownGlyph" Stretch="Uniform" VerticalAlignment="Center" Data="M1939 486L2029 576L1024 1581L19 576L109 486L1024 1401L1939 486Z" /> |
||||
MaxHeight="{TemplateBinding MaxDropDownHeight}" |
</Panel> |
||||
PlacementTarget="{TemplateBinding}" |
</Viewbox> |
||||
StaysOpen="False"> |
<Popup Name="PART_Popup" |
||||
<Border BorderBrush="{DynamicResource ThemeBorderMidBrush}" |
WindowManagerAddShadowHint="False" |
||||
BorderThickness="1"> |
IsOpen="{TemplateBinding IsDropDownOpen, Mode=TwoWay}" |
||||
<ScrollViewer> |
MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}" |
||||
<ItemsPresenter Name="PART_ItemsPresenter" |
MaxHeight="{TemplateBinding MaxDropDownHeight}" |
||||
Items="{TemplateBinding Items}" |
PlacementTarget="{TemplateBinding}" |
||||
ItemsPanel="{TemplateBinding ItemsPanel}" |
StaysOpen="False"> |
||||
ItemTemplate="{TemplateBinding ItemTemplate}" |
<Border x:Name="PopupBorder" |
||||
VirtualizationMode="{TemplateBinding VirtualizationMode}" |
Background="{DynamicResource ComboBoxDropDownBackground}" |
||||
|
BorderBrush="{DynamicResource ComboBoxDropDownBorderBrush}" |
||||
|
BorderThickness="{DynamicResource ComboBoxDropdownBorderThickness}" |
||||
|
Margin="0,-1,0,-1" |
||||
|
Padding="{DynamicResource ComboBoxDropdownBorderPadding}" |
||||
|
HorizontalAlignment="Stretch" |
||||
|
CornerRadius="{DynamicResource OverlayCornerRadius}"> |
||||
|
<ScrollViewer> |
||||
|
<ItemsPresenter Name="PART_ItemsPresenter" |
||||
|
Items="{TemplateBinding Items}" |
||||
|
Margin="{DynamicResource ComboBoxDropdownContentMargin}" |
||||
|
ItemsPanel="{TemplateBinding ItemsPanel}" |
||||
|
ItemTemplate="{TemplateBinding ItemTemplate}" |
||||
|
VirtualizationMode="{TemplateBinding VirtualizationMode}" |
||||
/> |
/> |
||||
</ScrollViewer> |
</ScrollViewer> |
||||
</Border> |
</Border> |
||||
</Popup> |
</Popup> |
||||
</Grid> |
</Grid> |
||||
</Border> |
|
||||
</ControlTemplate> |
</ControlTemplate> |
||||
</Setter> |
</Setter> |
||||
</Style> |
</Style> |
||||
<Style Selector="ComboBox:pointerover /template/ Border#border"> |
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderHighBrush}"/> |
<!-- NormalState --> |
||||
|
<Style Selector="ComboBox /template/ TextBlock#PlaceholderTextBlock"> |
||||
|
<Setter Property="Foreground" Value="{DynamicResource ComboBoxPlaceHolderForeground}"/> |
||||
</Style> |
</Style> |
||||
<Style Selector="ComboBox:disabled /template/ Border#border"> |
|
||||
<Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}" /> |
<Style Selector="ComboBox /template/ Path#DropDownGlyph"> |
||||
|
<Setter Property="Fill" Value="{DynamicResource ComboBoxDropDownGlyphForeground}"/> |
||||
</Style> |
</Style> |
||||
|
|
||||
|
<!-- PointerOver State --> |
||||
|
<Style Selector="ComboBox:pointerover /template/ Border#Background"> |
||||
|
<Setter Property="Background" Value="{DynamicResource ComboBoxBackgroundPointerOver}"/> |
||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxBorderBrushPointerOver}" /> |
||||
|
</Style> |
||||
|
|
||||
|
<!-- Pressed State --> |
||||
|
<Style Selector="ComboBox:pressed /template/ Border#Background"> |
||||
|
<Setter Property="Background" Value="{DynamicResource ComboBoxBackgroundPressed}"/> |
||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxBorderBrushPressed}" /> |
||||
|
</Style> |
||||
|
|
||||
|
<!-- Disabled State --> |
||||
|
<Style Selector="ComboBox:disabled /template/ Border#Background"> |
||||
|
<Setter Property="Background" Value="{DynamicResource ComboBoxBackgroundDisabled}"/> |
||||
|
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxBorderBrushDisabled}" /> |
||||
|
</Style> |
||||
|
|
||||
|
<Style Selector="ComboBox:disabled /template/ ContentPresenter#HeaderContentPresenter"> |
||||
|
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ComboBoxForegroundDisabled}"/> |
||||
|
</Style> |
||||
|
|
||||
|
<Style Selector="ComboBox:disabled /template/ ContentControl#ContentPresenter"> |
||||
|
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ComboBoxForegroundDisabled}"/> |
||||
|
</Style> |
||||
|
|
||||
|
<Style Selector="ComboBox:disabled /template/ TextBlock#PlaceholderTextBlock"> |
||||
|
<Setter Property="Foreground" Value="{DynamicResource ComboBoxForegroundDisabled}"/> |
||||
|
</Style> |
||||
|
|
||||
|
<Style Selector="ComboBox:disabled /template/ TextBlock#PlaceholderTextBlock"> |
||||
|
<Setter Property="Foreground" Value="{DynamicResource ComboBoxForegroundDisabled}"/> |
||||
|
</Style> |
||||
|
|
||||
|
<Style Selector="ComboBox:disabled /template/ Path#DropDownGlyph"> |
||||
|
<Setter Property="Fill" Value="{DynamicResource ComboBoxDropDownGlyphForegroundDisabled}"/> |
||||
|
</Style> |
||||
|
|
||||
|
<!-- Focused State --> |
||||
|
|
||||
|
<!-- Focus Pressed State --> |
||||
|
|
||||
|
<!-- Unfocused State --> |
||||
|
|
||||
</Styles> |
</Styles> |
||||
|
|||||
Loading…
Reference in new issue