319 lines
19 KiB
XML
319 lines
19 KiB
XML
<ResourceDictionary
|
|
xmlns="https://github.com/avaloniaui"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
x:CompileBindings="True">
|
|
<Design.PreviewWith>
|
|
<StackPanel Margin="20">
|
|
<ComboBoxItem>Hello World</ComboBoxItem>
|
|
<ComboBoxItem>Hello World</ComboBoxItem>
|
|
<ComboBoxItem IsSelected="True">Hello World</ComboBoxItem>
|
|
<ComboBox Width="100" SelectedIndex="0">
|
|
<ComboBoxItem>AAA</ComboBoxItem>
|
|
<ComboBoxItem>BBB</ComboBoxItem>
|
|
<ComboBoxItem>CCC</ComboBoxItem>
|
|
</ComboBox>
|
|
<ComboBox Width="100" PlaceholderText="Select">
|
|
<ComboBoxItem>AAA</ComboBoxItem>
|
|
<ComboBoxItem>BBB</ComboBoxItem>
|
|
<ComboBoxItem>CCC</ComboBoxItem>
|
|
</ComboBox>
|
|
<ComboBox
|
|
Width="100"
|
|
IsEnabled="False"
|
|
PlaceholderText="Select">
|
|
<ComboBoxItem>AAA</ComboBoxItem>
|
|
<ComboBoxItem>BBB</ComboBoxItem>
|
|
<ComboBoxItem>CCC</ComboBoxItem>
|
|
</ComboBox>
|
|
</StackPanel>
|
|
</Design.PreviewWith>
|
|
<ControlTheme x:Key="{x:Type ComboBox}" TargetType="ComboBox">
|
|
<Setter Property="Padding" Value="{DynamicResource ComboBoxSelectorDefaultPadding}" />
|
|
<Setter Property="FocusAdorner" Value="{x:Null}" />
|
|
<Setter Property="MaxDropDownHeight" Value="{DynamicResource ComboBoxPopupMaxDropDownHeight}" />
|
|
<Setter Property="Background" Value="{DynamicResource ComboBoxSelectorBackground}" />
|
|
<Setter Property="BackgroundSizing" Value="OuterBorderEdge" />
|
|
<Setter Property="BorderThickness" Value="{DynamicResource ComboBoxSelectorThickness}" />
|
|
<Setter Property="Cursor" Value="Hand" />
|
|
<Setter Property="CornerRadius" Value="{DynamicResource ComboBoxSelectorCornerRadius}" />
|
|
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
|
|
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
|
|
<Setter Property="HorizontalContentAlignment" Value="Left" />
|
|
<Setter Property="VerticalContentAlignment" Value="Center" />
|
|
<Setter Property="HorizontalAlignment" Value="Left" />
|
|
<Setter Property="VerticalAlignment" Value="Top" />
|
|
<Setter Property="MinHeight" Value="{DynamicResource ComboBoxDefaultHeight}" />
|
|
<Setter Property="Template">
|
|
<ControlTemplate TargetType="ComboBox">
|
|
<DataValidationErrors>
|
|
<Grid ColumnDefinitions="*, Auto">
|
|
<Border
|
|
Name="Background"
|
|
Grid.Column="0"
|
|
Grid.ColumnSpan="2"
|
|
Background="{TemplateBinding Background}"
|
|
BackgroundSizing="{TemplateBinding BackgroundSizing}"
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
BorderThickness="{TemplateBinding BorderThickness}"
|
|
CornerRadius="{TemplateBinding CornerRadius}"
|
|
MinHeight="{TemplateBinding MinHeight}" />
|
|
<TextBlock
|
|
Name="PlaceholderTextBlock"
|
|
Grid.Column="0"
|
|
Margin="{TemplateBinding Padding}"
|
|
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
|
TextTrimming="CharacterEllipsis"
|
|
Foreground="{TemplateBinding Foreground}"
|
|
IsVisible="{TemplateBinding SelectionBoxItem,Converter={x:Static ObjectConverters.IsNull}}"
|
|
Opacity="0.3"
|
|
Text="{TemplateBinding PlaceholderText}" />
|
|
<ContentPresenter
|
|
Name="ContentPresenter"
|
|
Grid.Column="0"
|
|
Margin="{TemplateBinding Padding}"
|
|
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
|
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
|
Content="{TemplateBinding SelectionBoxItem}"
|
|
ContentTemplate="{TemplateBinding ItemTemplate}" />
|
|
<Button
|
|
Name="ClearButton"
|
|
Grid.Column="1"
|
|
Theme="{DynamicResource InnerIconButton}"
|
|
Width="{DynamicResource ComboBoxIconWidth}"
|
|
Command="{Binding $parent[ComboBox].Clear}"
|
|
Content="{DynamicResource IconButtonClearData}"
|
|
Focusable="False"
|
|
IsVisible="False" />
|
|
|
|
<PathIcon
|
|
Name="DropDownGlyph"
|
|
Grid.Column="1"
|
|
Theme="{DynamicResource InnerPathIcon}"
|
|
Width="{DynamicResource ComboBoxIconWidth}"
|
|
Data="{DynamicResource ComboBoxIcon}"
|
|
Foreground="{DynamicResource ComboBoxIconDefaultForeground}"
|
|
IsHitTestVisible="False"
|
|
UseLayoutRounding="False" />
|
|
|
|
<Popup
|
|
Name="PART_Popup"
|
|
Grid.Column="0"
|
|
MaxHeight="{TemplateBinding MaxDropDownHeight}"
|
|
InheritsTransform="True"
|
|
IsLightDismissEnabled="True"
|
|
IsOpen="{TemplateBinding IsDropDownOpen,
|
|
Mode=TwoWay}"
|
|
PlacementTarget="Background"
|
|
WindowManagerAddShadowHint="False">
|
|
<Border
|
|
Name="PopupBorder"
|
|
HorizontalAlignment="Stretch"
|
|
MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}"
|
|
Margin="{DynamicResource ComboBoxPopupBorderMargin}"
|
|
Padding="{DynamicResource ComboBoxPopupBorderPadding}"
|
|
Background="{DynamicResource ComboBoxPopupBackground}"
|
|
BorderBrush="{DynamicResource ComboBoxPopupBorderBrush}"
|
|
BorderThickness="{DynamicResource ComboBoxPopupBorderThickness}"
|
|
BoxShadow="{DynamicResource ComboBoxPopupBoxShadow}"
|
|
CornerRadius="{DynamicResource ComboBoxPopupBoxCornerRadius}">
|
|
<ScrollViewer
|
|
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
|
|
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
|
|
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
|
|
<ItemsPresenter
|
|
Name="PART_ItemsPresenter"
|
|
ItemsPanel="{TemplateBinding ItemsPanel}" />
|
|
</ScrollViewer>
|
|
</Border>
|
|
</Popup>
|
|
</Grid>
|
|
</DataValidationErrors>
|
|
</ControlTemplate>
|
|
</Setter>
|
|
|
|
<Style Selector="^.clearButton, ^.ClearButton">
|
|
<Style Selector="^:pointerover /template/ Button#ClearButton">
|
|
<Setter Property="IsVisible" Value="{Binding $parent[ComboBox].SelectionBoxItem, Converter={x:Static ObjectConverters.IsNotNull}}" />
|
|
</Style>
|
|
<Style Selector="^:pointerover /template/ PathIcon#DropDownGlyph">
|
|
<Setter Property="IsVisible" Value="{Binding $parent[ComboBox].SelectionBoxItem, Converter={x:Static ObjectConverters.IsNull}}"/>
|
|
</Style>
|
|
</Style>
|
|
|
|
<Style Selector="^.Large">
|
|
<Setter Property="MinHeight" Value="{DynamicResource ComboBoxLargeHeight}" />
|
|
</Style>
|
|
<Style Selector="^.Small">
|
|
<Setter Property="MinHeight" Value="{DynamicResource ComboBoxSmallHeight}" />
|
|
</Style>
|
|
|
|
<!-- Pointerover State -->
|
|
<Style Selector="^:pointerover">
|
|
<Setter Property="Background" Value="{DynamicResource ComboBoxSelectorPointeroverBackground}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxSelectorPointeroverBorderBrush}" />
|
|
<Style Selector="^ /template/ PathIcon#DropDownGlyph">
|
|
<Setter Property="Foreground" Value="{DynamicResource ComboBoxIconPointeroverForeground}" />
|
|
</Style>
|
|
</Style>
|
|
|
|
<!-- Focus State -->
|
|
<Style Selector="^:focus">
|
|
<Setter Property="Background" Value="{DynamicResource ComboBoxSelectorFocusBackground}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxSelectorFocusBorderBrush}" />
|
|
<Style Selector="^ /template/ PathIcon#DropDownGlyph">
|
|
<Setter Property="Foreground" Value="{DynamicResource ComboBoxIconFocusForeground}" />
|
|
</Style>
|
|
</Style>
|
|
|
|
<!-- Pressed State -->
|
|
<Style Selector="^:pressed">
|
|
<Setter Property="Background" Value="{DynamicResource ComboBoxSelectorPressedBackground}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxSelectorPressedBorderBrush}" />
|
|
<Style Selector="^ /template/ PathIcon#DropDownGlyph">
|
|
<Setter Property="Foreground" Value="{DynamicResource ComboBoxIconPressedForeground}" />
|
|
</Style>
|
|
</Style>
|
|
|
|
<Style Selector="^:dropdownopen">
|
|
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxSelectorPressedBorderBrush}" />
|
|
</Style>
|
|
|
|
<!-- Disabled State -->
|
|
<Style Selector="^:disabled">
|
|
<Setter Property="Background" Value="{DynamicResource ComboBoxSelectorDisabledBackground}" />
|
|
<Style Selector="^ /template/ ContentControl#ContentPresenter">
|
|
<Setter Property="Foreground" Value="{DynamicResource ComboBoxDisabledForeground}" />
|
|
</Style>
|
|
<Style Selector="^ /template/ TextBlock#PlaceholderTextBlock">
|
|
<Setter Property="Foreground" Value="{DynamicResource ComboBoxDisabledForeground}" />
|
|
</Style>
|
|
<Style Selector="^ /template/ PathIcon#DropDownGlyph">
|
|
<Setter Property="Foreground" Value="{DynamicResource ComboBoxIconDisabledForeground}" />
|
|
</Style>
|
|
</Style>
|
|
<!-- Error State -->
|
|
<Style Selector="^:error">
|
|
<Style Selector="^ /template/ Border#Background">
|
|
<Setter Property="Background" Value="{DynamicResource DataValidationErrorsBackground}" />
|
|
</Style>
|
|
<Style Selector="^:pointerover /template/ Border#Background">
|
|
<Setter Property="Background" Value="{DynamicResource DataValidationErrorsPointerOverBackground}" />
|
|
<Setter Property="BorderBrush" Value="Transparent" />
|
|
</Style>
|
|
<Style Selector="^:pressed /template/ Border#Background">
|
|
<Setter Property="Background" Value="{DynamicResource DataValidationErrorsPressedBackground}" />
|
|
<Setter Property="BorderBrush" Value="Transparent" />
|
|
</Style>
|
|
<Style Selector="^:focus /template/ Border#Background">
|
|
<Setter Property="Background" Value="{DynamicResource DataValidationErrorsSelectedBackground}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource DataValidationErrorsSelectedBorderBrush}" />
|
|
</Style>
|
|
</Style>
|
|
|
|
<Style Selector="^.Bordered">
|
|
<Style Selector="^ /template/ Border#Background">
|
|
<Setter Property="Background" Value="{DynamicResource ComboBoxSelectorBorderedBackground}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxSelectorBorderedBorderBrush}" />
|
|
</Style>
|
|
<Style Selector="^:pointerover /template/ Border#Background">
|
|
<Setter Property="Background" Value="{DynamicResource ComboBoxSelectorBorderedPointeroverBackground}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxSelectorBorderedPointeroverBorderBrush}" />
|
|
</Style>
|
|
<Style Selector="^:pressed /template/ Border#Background">
|
|
<Setter Property="Background" Value="{DynamicResource ComboBoxSelectorBorderedPressedBackground}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxSelectorBorderedPressedBorderBrush}" />
|
|
</Style>
|
|
<Style Selector="^:focus /template/ Border#Background">
|
|
<Setter Property="Background" Value="{DynamicResource ComboBoxSelectorBorderedFocusBackground}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxSelectorBorderedFocusBorderBrush}" />
|
|
</Style>
|
|
<Style Selector="^:disabled">
|
|
<Style Selector="^ /template/ Border#Background">
|
|
<Setter Property="Background" Value="{DynamicResource ComboBoxSelectorDisabledBackground}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxSelectorBorderBrush}" />
|
|
</Style>
|
|
<Style Selector="^ /template/ ContentControl#ContentPresenter">
|
|
<Setter Property="Foreground" Value="{DynamicResource ComboBoxDisabledForeground}" />
|
|
</Style>
|
|
<Style Selector="^ /template/ TextBlock#PlaceholderTextBlock">
|
|
<Setter Property="Foreground" Value="{DynamicResource ComboBoxDisabledForeground}" />
|
|
</Style>
|
|
<Style Selector="^ /template/ PathIcon#DropDownGlyph">
|
|
<Setter Property="Foreground" Value="{DynamicResource ComboBoxIconDisabledForeground}" />
|
|
</Style>
|
|
</Style>
|
|
<Style Selector="^:error">
|
|
<Style Selector="^ /template/ Border#Background">
|
|
<Setter Property="Background" Value="{DynamicResource DataValidationErrorsBackground}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource DataValidationErrorsBorderBrush}" />
|
|
</Style>
|
|
<Style Selector="^:pointerover /template/ Border#Background">
|
|
<Setter Property="Background" Value="{DynamicResource DataValidationErrorsPointerOverBackground}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource DataValidationErrorsPointerOverBorderBrush}" />
|
|
</Style>
|
|
<Style Selector="^:pressed /template/ Border#Background">
|
|
<Setter Property="Background" Value="{DynamicResource DataValidationErrorsPressedBackground}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource DataValidationErrorsPressedBorderBrush}" />
|
|
</Style>
|
|
<Style Selector="^:focus /template/ Border#Background">
|
|
<Setter Property="Background" Value="{DynamicResource DataValidationErrorsSelectedBackground}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource DataValidationErrorsSelectedBorderBrush}" />
|
|
</Style>
|
|
</Style>
|
|
</Style>
|
|
</ControlTheme>
|
|
|
|
<ControlTheme x:Key="{x:Type ComboBoxItem}" TargetType="ComboBoxItem">
|
|
<Setter Property="Foreground" Value="{DynamicResource ComboBoxItemForeground}" />
|
|
<Setter Property="Background" Value="{DynamicResource ComboBoxItemBackground}" />
|
|
<Setter Property="Padding" Value="{DynamicResource ComboBoxItemDefaultPadding}" />
|
|
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
|
<Setter Property="Template">
|
|
<ControlTemplate TargetType="ComboBoxItem">
|
|
<ContentPresenter
|
|
Name="PART_ContentPresenter"
|
|
Padding="{TemplateBinding Padding}"
|
|
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
|
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
|
Background="{TemplateBinding Background}"
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
BorderThickness="{TemplateBinding BorderThickness}"
|
|
Content="{TemplateBinding Content}"
|
|
ContentTemplate="{TemplateBinding ContentTemplate}"
|
|
CornerRadius="{TemplateBinding CornerRadius}"
|
|
Foreground="{TemplateBinding Foreground}" />
|
|
</ControlTemplate>
|
|
</Setter>
|
|
|
|
<Style Selector="^:pointerover /template/ ContentPresenter#PART_ContentPresenter">
|
|
<Setter Property="Background" Value="{DynamicResource ComboBoxItemPointeroverBackground}" />
|
|
</Style>
|
|
|
|
<Style Selector="^:focus /template/ ContentPresenter#PART_ContentPresenter">
|
|
<Setter Property="Background" Value="{DynamicResource ComboBoxItemFocusBackground}" />
|
|
</Style>
|
|
|
|
<Style Selector="^:disabled /template/ ContentPresenter#PART_ContentPresenter">
|
|
<Setter Property="Background" Value="{DynamicResource ComboBoxItemDisabledBackground}" />
|
|
</Style>
|
|
|
|
<Style Selector="^:pressed /template/ ContentPresenter#PART_ContentPresenter">
|
|
<Setter Property="Background" Value="{DynamicResource ComboBoxItemPressedBackground}" />
|
|
</Style>
|
|
|
|
<Style Selector="^:selected">
|
|
<Style Selector="^ /template/ ContentPresenter#PART_ContentPresenter">
|
|
<Setter Property="Background" Value="{DynamicResource ComboBoxItemSelectedBackground}" />
|
|
</Style>
|
|
<Style Selector="^:disabled /template/ ContentPresenter#PART_ContentPresenter">
|
|
<Setter Property="Background" Value="{DynamicResource ComboBoxItemSelectedDisabledBackground}" />
|
|
</Style>
|
|
<Style Selector="^:pointerover /template/ ContentPresenter#PART_ContentPresenter">
|
|
<Setter Property="Background" Value="{DynamicResource ComboBoxItemSelectedPointeroverBackground}" />
|
|
</Style>
|
|
</Style>
|
|
|
|
</ControlTheme>
|
|
</ResourceDictionary>
|