Browse Source

Fluent2: paint window canvas via tree-anchored resource in template

When the theme is materialized as a deferred keyed resource (as ControlCatalog
declares it in App.xaml) the Window ControlTheme's Background styled setter
never resolves its DynamicResource, leaving the white transparency fallback
visible under semi-transparent page layers — dark mode composited to light
gray. Inner controls were unaffected because template-level DynamicResource
resolves through the visual tree.

Add a canvas border in the window template that paints
SolidBackgroundFillColorBaseBrush via the tree-anchored path; a user-set
Background still paints over it via the existing TemplateBinding border.
The styled-setter anomaly itself is an Avalonia core issue to investigate.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
pull/21771/head
Mike James 3 months ago
parent
commit
a71bbb56ea
  1. 7
      src/Avalonia.Themes.Fluent2/Controls/Window.xaml

7
src/Avalonia.Themes.Fluent2/Controls/Window.xaml

@ -15,6 +15,13 @@
<ControlTemplate>
<Panel>
<Border Name="PART_TransparencyFallback" IsHitTestVisible="False" />
<!-- Default canvas painted via a tree-anchored DynamicResource: styled-setter
DynamicResources on TopLevels have failed to resolve in hosted/reopened
window scenarios, leaving the white transparency fallback visible.
A user-set Background still paints over this via the border above it. -->
<Border Name="PART_Fluent2CanvasBackground"
Background="{DynamicResource SolidBackgroundFillColorBaseBrush}"
IsHitTestVisible="False" />
<Border Background="{TemplateBinding Background}" IsHitTestVisible="False" />
<Panel Background="Transparent" Margin="{TemplateBinding WindowDecorationMargin}" />
<VisualLayerManager Name="PART_VisualLayerManager">

Loading…
Cancel
Save