Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions DialogHost.Avalonia/DialogHostStyles.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ bool IResourceNode.TryGetResource(object key, ThemeVariant? theme, out object? v
}
}

value = Brushes.Black;
value = ResolveFallbackBrush(theme);
return true;
}

Expand All @@ -79,10 +79,31 @@ bool IResourceNode.TryGetResource(object key, ThemeVariant? theme, out object? v
}
}

value = Brushes.Black;
value = ResolveFallbackBrush(theme);
return true;
}

return base.TryGetResource(key, theme, out value);
}

private IBrush ResolveFallbackBrush(ThemeVariant? theme) {
// No theme - look global
if (theme is null) {
return Application.Current?.ActualThemeVariant is not null
? ResolveFallbackBrush(Application.Current.ActualThemeVariant)
: Brushes.Gray; // Or return fallback
}

if (theme == ThemeVariant.Light || theme.Key == ThemeVariant.Light.Key) {
return Brushes.White;
}

if (theme == ThemeVariant.Dark || theme.Key == ThemeVariant.Dark.Key) {
return Brushes.Black;
}

return theme.InheritVariant is not null
? ResolveFallbackBrush(theme.InheritVariant)
: Brushes.Gray;
}
}