Skip to content

Commit 5c75878

Browse files
authored
Align Avalonia UI with WinUI styling and behavior (#4975)
1 parent 94b6f20 commit 5c75878

39 files changed

Lines changed: 890 additions & 357 deletions

‎src/UniGetUI.Avalonia/Assets/Styles/Styles.Common.axaml‎

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
<SolidColorBrush x:Key="AccentFillColorTertiaryBrush" Color="{DynamicResource SystemAccentColorDark2}"/>
1414
<SolidColorBrush x:Key="AccentFillColorDisabledBrush" Color="#37000000"/>
1515
<SolidColorBrush x:Key="AccentFillColorSelectedTextBackgroundBrush" Color="{DynamicResource SystemAccentColor}"/>
16+
<!-- Subtle fills (WinUI NavigationViewItem hover/selected backgrounds) -->
17+
<SolidColorBrush x:Key="SubtleFillColorSecondaryBrush" Color="#09000000"/>
18+
<SolidColorBrush x:Key="SubtleFillColorTertiaryBrush" Color="#06000000"/>
1619
<!-- Accent text (darker accents read better on light bg) -->
1720
<SolidColorBrush x:Key="AccentTextFillColorPrimaryBrush" Color="{DynamicResource SystemAccentColorDark2}"/>
1821
<SolidColorBrush x:Key="AccentTextFillColorSecondaryBrush" Color="{DynamicResource SystemAccentColorDark3}"/>
@@ -35,6 +38,14 @@
3538
<SolidColorBrush x:Key="SettingsCardBackground" Color="#FBFBFB"/>
3639
<SolidColorBrush x:Key="SettingsCardBorderBrush" Color="#ECECEC"/>
3740
<SolidColorBrush x:Key="SettingsCardHoverBackground" Color="#F6F6F6"/>
41+
<!-- Package list container; near-transparent over Mica (see Styles.WindowsMica) -->
42+
<SolidColorBrush x:Key="PackageListBackground" Color="#FBFBFB"/>
43+
<!-- Column header: WinUI default button (ControlFillColorDefault fill + ControlStrokeColorDefault border) -->
44+
<SolidColorBrush x:Key="PackageListHeaderBackground" Color="#B3FFFFFF"/>
45+
<SolidColorBrush x:Key="PackageListHeaderBorderBrush" Color="#0F000000"/>
46+
<!-- Subtle header hover/press (WinUI-style), over the rest fill -->
47+
<SolidColorBrush x:Key="DataGridColumnHeaderHoveredBackgroundBrush" Color="#05000000"/>
48+
<SolidColorBrush x:Key="DataGridColumnHeaderPressedBackgroundBrush" Color="#14000000"/>
3849
<!-- Window structure -->
3950
<SolidColorBrush x:Key="AppWindowBackground" Color="#F3F3F3"/>
4051
<SolidColorBrush x:Key="AppTitleBarBackground" Color="#F3F3F3"/>
@@ -78,6 +89,9 @@
7889
<SolidColorBrush x:Key="AccentFillColorTertiaryBrush" Color="{DynamicResource SystemAccentColor}"/>
7990
<SolidColorBrush x:Key="AccentFillColorDisabledBrush" Color="#28FFFFFF"/>
8091
<SolidColorBrush x:Key="AccentFillColorSelectedTextBackgroundBrush" Color="{DynamicResource SystemAccentColor}"/>
92+
<!-- Subtle fills (WinUI NavigationViewItem hover/selected backgrounds) -->
93+
<SolidColorBrush x:Key="SubtleFillColorSecondaryBrush" Color="#0FFFFFFF"/>
94+
<SolidColorBrush x:Key="SubtleFillColorTertiaryBrush" Color="#0AFFFFFF"/>
8195
<!-- Accent text -->
8296
<SolidColorBrush x:Key="AccentTextFillColorPrimaryBrush" Color="{DynamicResource SystemAccentColorLight3}"/>
8397
<SolidColorBrush x:Key="AccentTextFillColorSecondaryBrush" Color="{DynamicResource SystemAccentColorLight3}"/>
@@ -99,6 +113,14 @@
99113
<SolidColorBrush x:Key="SettingsCardBackground" Color="#2D2D2D"/>
100114
<SolidColorBrush x:Key="SettingsCardBorderBrush" Color="#393939"/>
101115
<SolidColorBrush x:Key="SettingsCardHoverBackground" Color="#323232"/>
116+
<!-- Package list container; near-transparent over Mica (see Styles.WindowsMica) -->
117+
<SolidColorBrush x:Key="PackageListBackground" Color="#2D2D2D"/>
118+
<!-- Column header: WinUI default button (ControlFillColorDefault fill + ControlStrokeColorDefault border) -->
119+
<SolidColorBrush x:Key="PackageListHeaderBackground" Color="#0FFFFFFF"/>
120+
<SolidColorBrush x:Key="PackageListHeaderBorderBrush" Color="#12FFFFFF"/>
121+
<!-- Subtle header hover/press (WinUI-style), over the rest fill -->
122+
<SolidColorBrush x:Key="DataGridColumnHeaderHoveredBackgroundBrush" Color="#0AFFFFFF"/>
123+
<SolidColorBrush x:Key="DataGridColumnHeaderPressedBackgroundBrush" Color="#1FFFFFFF"/>
102124
<!-- Window structure -->
103125
<SolidColorBrush x:Key="AppWindowBackground" Color="#202020"/>
104126
<SolidColorBrush x:Key="AppTitleBarBackground" Color="#202020"/>
@@ -147,6 +169,10 @@
147169
<Setter Property="BorderThickness" Value="2"/>
148170
<Setter Property="BorderBrush" Value="Transparent"/>
149171
</Style>
172+
<!-- Column headers default to Avalonia's 12px bare-TextBlock size; WinUI renders them at 14px. -->
173+
<Style Selector="DataGridColumnHeader">
174+
<Setter Property="FontSize" Value="14"/>
175+
</Style>
150176
<Style Selector="DataGridRow:selected">
151177
<Setter Property="BorderBrush" Value="{DynamicResource SystemAccentColor}"/>
152178
</Style>
@@ -157,6 +183,96 @@
157183
<Setter Property="Fill" Value="{DynamicResource SettingsCardHoverBackground}"/>
158184
</Style>
159185

186+
<!-- Sidebar navigation items: WinUI NavigationViewItem-style selection.
187+
Fluent's default fills the selected item with the accent colour; instead use a subtle
188+
neutral fill plus a vertical accent pill on the left edge. The content presenter is named
189+
ContentHost (not PART_ContentPresenter) so the base theme's accent-fill setters don't apply. -->
190+
<Style Selector="ListBoxItem.nav-item">
191+
<Setter Property="Template">
192+
<ControlTemplate>
193+
<Panel>
194+
<ContentPresenter Name="ContentHost"
195+
Background="{TemplateBinding Background}"
196+
BorderBrush="{TemplateBinding BorderBrush}"
197+
BorderThickness="{TemplateBinding BorderThickness}"
198+
CornerRadius="{TemplateBinding CornerRadius}"
199+
ContentTemplate="{TemplateBinding ContentTemplate}"
200+
Content="{TemplateBinding Content}"
201+
Padding="{TemplateBinding Padding}"
202+
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
203+
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"/>
204+
<Border Name="SelectionPill"
205+
Width="3" Height="16" CornerRadius="1.5"
206+
Background="{DynamicResource AccentFillColorDefaultBrush}"
207+
HorizontalAlignment="Left" VerticalAlignment="Center"
208+
Opacity="0">
209+
<Border.Transitions>
210+
<Transitions><DoubleTransition Property="Opacity" Duration="0:0:0.1"/></Transitions>
211+
</Border.Transitions>
212+
</Border>
213+
</Panel>
214+
</ControlTemplate>
215+
</Setter>
216+
</Style>
217+
<Style Selector="ListBoxItem.nav-item:pointerover /template/ ContentPresenter#ContentHost">
218+
<Setter Property="Background" Value="{DynamicResource SubtleFillColorSecondaryBrush}"/>
219+
</Style>
220+
<Style Selector="ListBoxItem.nav-item:pressed /template/ ContentPresenter#ContentHost">
221+
<Setter Property="Background" Value="{DynamicResource SubtleFillColorTertiaryBrush}"/>
222+
</Style>
223+
<Style Selector="ListBoxItem.nav-item:selected /template/ ContentPresenter#ContentHost">
224+
<Setter Property="Background" Value="{DynamicResource SubtleFillColorSecondaryBrush}"/>
225+
</Style>
226+
<Style Selector="ListBoxItem.nav-item:selected:pointerover /template/ ContentPresenter#ContentHost">
227+
<Setter Property="Background" Value="{DynamicResource SubtleFillColorTertiaryBrush}"/>
228+
</Style>
229+
<Style Selector="ListBoxItem.nav-item:selected /template/ Border#SelectionPill">
230+
<Setter Property="Opacity" Value="1"/>
231+
</Style>
232+
233+
<!-- View-mode segmented selector (List / Grid / Icons): WinUI Segmented-style selection — subtle
234+
fill plus an accent underline under the selected segment, not Fluent's full-accent fill. -->
235+
<Style Selector="ListBoxItem.segment-item">
236+
<Setter Property="Template">
237+
<ControlTemplate>
238+
<Panel>
239+
<ContentPresenter Name="ContentHost"
240+
Background="{TemplateBinding Background}"
241+
BorderBrush="{TemplateBinding BorderBrush}"
242+
BorderThickness="{TemplateBinding BorderThickness}"
243+
CornerRadius="{TemplateBinding CornerRadius}"
244+
ContentTemplate="{TemplateBinding ContentTemplate}"
245+
Content="{TemplateBinding Content}"
246+
Padding="{TemplateBinding Padding}"
247+
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
248+
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"/>
249+
<Border Name="SelectionPill"
250+
Height="2" CornerRadius="1"
251+
Background="{DynamicResource AccentFillColorDefaultBrush}"
252+
HorizontalAlignment="Stretch" VerticalAlignment="Bottom"
253+
Margin="5,0,5,2"
254+
Opacity="0">
255+
<Border.Transitions>
256+
<Transitions><DoubleTransition Property="Opacity" Duration="0:0:0.1"/></Transitions>
257+
</Border.Transitions>
258+
</Border>
259+
</Panel>
260+
</ControlTemplate>
261+
</Setter>
262+
</Style>
263+
<Style Selector="ListBoxItem.segment-item:pointerover /template/ ContentPresenter#ContentHost">
264+
<Setter Property="Background" Value="{DynamicResource SubtleFillColorSecondaryBrush}"/>
265+
</Style>
266+
<Style Selector="ListBoxItem.segment-item:selected /template/ ContentPresenter#ContentHost">
267+
<Setter Property="Background" Value="{DynamicResource SubtleFillColorSecondaryBrush}"/>
268+
</Style>
269+
<Style Selector="ListBoxItem.segment-item:selected:pointerover /template/ ContentPresenter#ContentHost">
270+
<Setter Property="Background" Value="{DynamicResource SubtleFillColorTertiaryBrush}"/>
271+
</Style>
272+
<Style Selector="ListBoxItem.segment-item:selected /template/ Border#SelectionPill">
273+
<Setter Property="Opacity" Value="1"/>
274+
</Style>
275+
160276
<!-- SettingsCard appearance -->
161277
<Style Selector="Border.settings-card">
162278
<Setter Property="Background" Value="{DynamicResource SettingsCardBackground}"/>

‎src/UniGetUI.Avalonia/Assets/Styles/Styles.WindowsMica.axaml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
<!-- Cards / panels: translucent white layers over the (light) Mica -->
1818
<SolidColorBrush x:Key="SettingsCardBackground" Color="#80FFFFFF"/>
1919
<SolidColorBrush x:Key="SettingsCardBorderBrush" Color="#14000000"/>
20+
<!-- Package list: near-transparent so Mica shows through, matching WinUI's SystemFillColorNeutralBackground -->
21+
<SolidColorBrush x:Key="PackageListBackground" Color="#06000000"/>
2022
<SolidColorBrush x:Key="SettingsCardHoverBackground" Color="#99FFFFFF"/>
2123
<SolidColorBrush x:Key="AppSplitterBackground" Color="#18000000"/>
2224
<SolidColorBrush x:Key="AppOperationsPanelBackground" Color="#80FFFFFF"/>
@@ -53,6 +55,8 @@
5355
<!-- Cards / panels: translucent dark layers; ~40% so the wallpaper-tinted Mica bleeds through -->
5456
<SolidColorBrush x:Key="SettingsCardBackground" Color="#662D2D2D"/>
5557
<SolidColorBrush x:Key="SettingsCardBorderBrush" Color="#26FFFFFF"/>
58+
<!-- Package list: near-transparent so Mica shows through, matching WinUI's SystemFillColorNeutralBackground -->
59+
<SolidColorBrush x:Key="PackageListBackground" Color="#08FFFFFF"/>
5660
<SolidColorBrush x:Key="SettingsCardHoverBackground" Color="#66383838"/>
5761
<SolidColorBrush x:Key="AppSplitterBackground" Color="#66000000"/>
5862
<SolidColorBrush x:Key="AppOperationsPanelBackground" Color="#66202020"/>

‎src/UniGetUI.Avalonia/Models/PackageCollections.cs‎

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ public bool IsChecked
6565
public string VersionComboString { get; }
6666
public string ListedNameTooltip { get; private set; } = "";
6767
public float ListedOpacity { get; private set; } = 1.0f;
68-
public string TagIconPath { get; private set; } = "";
68+
public string TagBackdropIconPath { get; private set; } = "";
69+
public string TagSymbolIconPath { get; private set; } = "";
6970
public bool TagIconVisible { get; private set; }
7071

7172
public bool InstallerHostChanged { get; private set; }
@@ -248,7 +249,8 @@ private void Package_PropertyChanged(object? sender, PropertyChangedEventArgs e)
248249
UpdateDisplayState();
249250
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ListedOpacity)));
250251
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ListedNameTooltip)));
251-
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(TagIconPath)));
252+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(TagBackdropIconPath)));
253+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(TagSymbolIconPath)));
252254
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(TagIconVisible)));
253255
}
254256
else if (e.PropertyName == nameof(Package.IsChecked))
@@ -270,20 +272,20 @@ private void UpdateDisplayState()
270272
};
271273
ListedNameTooltip = Package.Name;
272274

273-
string tagName = Package.Tag switch
275+
// Match WinUI: an accent-coloured filled disc with the symbol punched out, then the
276+
// symbol drawn on top in the default foreground. OnQueue/Unavailable show no badge.
277+
(string symbol, string backdrop) = Package.Tag switch
274278
{
275-
PackageTag.AlreadyInstalled => "installed_filled",
276-
PackageTag.IsUpgradable => "upgradable_filled",
277-
PackageTag.Pinned => "pin_filled",
278-
PackageTag.OnQueue => "sandclock",
279-
PackageTag.BeingProcessed => "loading_filled",
280-
PackageTag.Failed => "warning_filled",
281-
_ => "",
279+
PackageTag.AlreadyInstalled => ("installed", "installed_filled"),
280+
PackageTag.IsUpgradable => ("upgradable", "upgradable_filled"),
281+
PackageTag.Pinned => ("pin", "pin_filled"),
282+
PackageTag.BeingProcessed => ("loading", "loading_filled"),
283+
PackageTag.Failed => ("warning", "warning_filled"),
284+
_ => ("", ""),
282285
};
283-
TagIconVisible = tagName.Length > 0;
284-
TagIconPath = TagIconVisible
285-
? $"avares://UniGetUI.Avalonia/Assets/Symbols/{tagName}.svg"
286-
: "";
286+
TagIconVisible = symbol.Length > 0;
287+
TagSymbolIconPath = TagIconVisible ? $"avares://UniGetUI.Avalonia/Assets/Symbols/{symbol}.svg" : "";
288+
TagBackdropIconPath = TagIconVisible ? $"avares://UniGetUI.Avalonia/Assets/Symbols/{backdrop}.svg" : "";
287289
}
288290

289291
public void Dispose()

‎src/UniGetUI.Avalonia/UniGetUI.Avalonia.csproj‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@
130130
<PackageReference Include="Avalonia.Controls.DataGrid" Version="12.0.0" />
131131
<PackageReference Include="Avalonia.Desktop" Version="12.0.4" />
132132
<PackageReference Include="Avalonia.Themes.Fluent" Version="12.0.4" />
133-
<PackageReference Include="Devolutions.AvaloniaTheme.DevExpress" Version="2026.3.13" />
134133
<PackageReference Include="Devolutions.AvaloniaTheme.MacOS" Version="2026.3.13" />
135134
<PackageReference Include="Devolutions.AvaloniaTheme.Linux" Version="2026.3.11" />
136135
<PackageReference Include="AvaloniaUI.DiagnosticsSupport" Version="2.2.0-beta3" Condition="'$(EnableAvaloniaDiagnostics)' == 'true'" />

0 commit comments

Comments
 (0)