C
C#14mo ago
Mekasu0124

✅ 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.
No description
1 Reply
Mekasu0124
Mekasu0124OP14mo ago
I got it figured out
Want results from more Discord servers?
Add your server