© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
1 reply
Mek

✅ Styling ComboBox Avalonia

<Style Selector="ComboBox.HomeCombo">
    <Setter Property="Foreground" 
            Value="{DynamicResource ResourceKey=DarkGrayBrush}" />
    <Setter Property="Background" 
            Value="{DynamicResource ResourceKey=PurpleBrush}" />
    <Setter Property="HorizontalAlignment" 
            Value="Center" />
    <Setter Property="VerticalAlignment" 
            Value="Center" />
    <Setter Property="HorizontalContentAlignment" 
            Value="Center" />
    <Setter Property="VerticalContentAlignment" 
            Value="Center" />
    <Setter Property="Width" Value="300" />
    <Setter Property="Height" Value="70" />
    <Setter Property="FontSize" Value="20" />

    <Style Selector="^:pointerover /template/ Border#Background">
        <Setter Property="Background"
                Value="{DynamicResource ResourceKey=PinkBrush}" />
    </Style>
</Style>
    
<Style Selector="ComboBoxItem:pointerover /template/ ContentPresenter">
    <Setter Property="Background" 
            Value="{DynamicResource ResourceKey=PinkBrush}" />
    <Setter Property="BorderBrush" 
            Value="{DynamicResource ResourceKey=PinkBrush}" />
    <Setter Property="TextBlock.Foreground" 
            Value="{DynamicResource ResourceKey=DarkGrayBrush}" />
</Style>
<Style Selector="ComboBox.HomeCombo">
    <Setter Property="Foreground" 
            Value="{DynamicResource ResourceKey=DarkGrayBrush}" />
    <Setter Property="Background" 
            Value="{DynamicResource ResourceKey=PurpleBrush}" />
    <Setter Property="HorizontalAlignment" 
            Value="Center" />
    <Setter Property="VerticalAlignment" 
            Value="Center" />
    <Setter Property="HorizontalContentAlignment" 
            Value="Center" />
    <Setter Property="VerticalContentAlignment" 
            Value="Center" />
    <Setter Property="Width" Value="300" />
    <Setter Property="Height" Value="70" />
    <Setter Property="FontSize" Value="20" />

    <Style Selector="^:pointerover /template/ Border#Background">
        <Setter Property="Background"
                Value="{DynamicResource ResourceKey=PinkBrush}" />
    </Style>
</Style>
    
<Style Selector="ComboBoxItem:pointerover /template/ ContentPresenter">
    <Setter Property="Background" 
            Value="{DynamicResource ResourceKey=PinkBrush}" />
    <Setter Property="BorderBrush" 
            Value="{DynamicResource ResourceKey=PinkBrush}" />
    <Setter Property="TextBlock.Foreground" 
            Value="{DynamicResource ResourceKey=DarkGrayBrush}" />
</Style>
I'm trying to get the overall background to be purple, and when the user selects and item and then reopens the text box, the selected item is background pink instead of blue foreground dark gray instead of black. I've looked all over the https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Themes.Fluent/Controls/ComboBox.xaml file for the stylings, and I can't find what matches.
image.png
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

❔ Avalonia ComboBox SelectedValuePath
C#CC# / help
3y ago
Flyout Styling (Avalonia)
C#CC# / help
16mo ago
Styling in Avalonia
C#CC# / help
2y ago
✅ Styling Expander Avalonia
C#CC# / help
3y ago