Skip to content

Commit

Permalink
Redefine ComboBoxItem control theme
Browse files Browse the repository at this point in the history
  • Loading branch information
acidicMercury8 committed Apr 24, 2024
1 parent 6a23c65 commit 9885b00
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<ResourceDictionary
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith>
<Border Padding="20">
<StackPanel Orientation="Vertical">
<ComboBoxItem>ComboBoxItem 1</ComboBoxItem>
<ComboBoxItem>ComboBoxItem 2 long</ComboBoxItem>
<ComboBoxItem IsSelected="True">ComboBoxItem 3</ComboBoxItem>
<ComboBoxItem IsEnabled="False">ComboBoxItem 4</ComboBoxItem>
<ComboBoxItem
IsEnabled="False"
IsSelected="True">
ComboBoxItem 5
</ComboBoxItem>
</StackPanel>
</Border>
</Design.PreviewWith>

<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 ComboBoxItemThemePadding}" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />

<Setter Property="Template">
<ControlTemplate>
<ContentPresenter
x:Name="PART_ContentPresenter"
Content="{TemplateBinding Content}"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
ContentTemplate="{TemplateBinding ContentTemplate}"
CornerRadius="{TemplateBinding CornerRadius}"
Foreground="{TemplateBinding Foreground}" />
</ControlTemplate>
</Setter>

<Style Selector="^:pointerover /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource ComboBoxItemBackgroundPointerOver}" />
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushPointerOver}" />
<Setter Property="Foreground" Value="{DynamicResource ComboBoxItemForegroundPointerOver}" />
</Style>
<Style Selector="^:pressed /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource ComboBoxItemBackgroundPressed}" />
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushPressed}" />
<Setter Property="Foreground" Value="{DynamicResource ComboBoxItemForegroundPressed}" />
</Style>

<Style Selector="^:selected">
<Style Selector="^ /template/ ContentPresenter">
<Setter Property="Background" Value="LightGray" />
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushSelected}" />
<Setter Property="Foreground" Value="{DynamicResource ComboBoxItemForegroundSelected}" />
</Style>

<Style Selector="^:disabled /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource ComboBoxItemBackgroundSelectedDisabled}" />
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushSelectedDisabled}" />
<Setter Property="Foreground" Value="{DynamicResource ComboBoxItemForegroundSelectedDisabled}" />
</Style>
<Style Selector="^:pointerover /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource ComboBoxItemBackgroundSelectedPointerOver}" />
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushSelectedPointerOver}" />
<Setter Property="Foreground" Value="{DynamicResource ComboBoxItemForegroundSelectedPointerOver}" />
</Style>
<Style Selector="^:pressed /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource ComboBoxItemBackgroundSelectedPressed}" />
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushSelectedPressed}" />
<Setter Property="Foreground" Value="{DynamicResource ComboBoxItemForegroundSelectedPressed}" />
</Style>
</Style>

<Style Selector="^:disabled /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource ComboBoxItemBackgroundDisabled}" />
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushDisabled}" />
<Setter Property="Foreground" Value="{DynamicResource ComboBoxItemForegroundDisabled}" />
</Style>
</ControlTheme>
</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<ResourceDictionary.MergedDictionaries>
<ResourceInclude Source="avares://ImeSense.Launchers.Belarus.Themes.Avalonia/Styles/Border.axaml" />
<ResourceInclude Source="avares://ImeSense.Launchers.Belarus.Themes.Avalonia/Styles/Button.axaml" />
<ResourceInclude Source="avares://ImeSense.Launchers.Belarus.Themes.Avalonia/Styles/ComboBoxItem.axaml" />
<ResourceInclude Source="avares://ImeSense.Launchers.Belarus.Themes.Avalonia/Styles/TextBlock.axaml" />
<ResourceInclude Source="avares://ImeSense.Launchers.Belarus.Themes.Avalonia/Styles/TextBox.axaml" />
</ResourceDictionary.MergedDictionaries>
Expand Down

0 comments on commit 9885b00

Please sign in to comment.