Skip to content

Commit 6055088

Browse files
authored
Revise SystemBackdropHost Spec for clarity and consistency
Updated the documentation for SystemBackdropHost to improve clarity and consistency. Adjusted wording for better readability and fixed minor grammatical issues.
1 parent db879ec commit 6055088

File tree

1 file changed

+67
-45
lines changed

1 file changed

+67
-45
lines changed

specs/SystemBackdropHost Spec.md

Lines changed: 67 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,56 +3,57 @@ SystemBackdropHost
33

44
# Background
55

6-
System backdrop materials such as Mica, Acrylic, and future platform-provided surfaces are delivered through the
7-
`Microsoft.UI.Xaml.Media.SystemBackdrop` API surface. When apps want to expose these surfaces inside specific areas in the UI (as opposed to applying them to the full window), they need a XAML element that can connect the backdrop to the
8-
visual tree, manage its lifetime, and clip it to the intended layout bounds. Today, the only supported way to host a
9-
system backdrop is at the window level, which makes it awkward to layer the effect behind individual sections of UI or
10-
inside islands.
6+
System backdrop materials such as Mica, Acrylic etc are delivered through
7+
`Microsoft.UI.Xaml.Media.SystemBackdrop`. When you want to expose those materials inside a specific region of your UI
8+
rather than across an entire window, you need an element that can connect the backdrop to the visual tree, manage its
9+
lifetime, and clip it to the layout bounds. Today, you can only host a system backdrop at the window level, which makes
10+
it awkward to layer the effect behind individual sections of content or inside islands. There is no public stable API available
11+
in composition layer as well which allow apps to add backdrops in a specific area.
1112

1213
`SystemBackdropHost` is a lightweight `FrameworkElement` that bridges between the XAML tree and the composition
13-
infrastructure required by `SystemBackdrop`. It automatically creates the composition link that a backdrop needs,
14-
maintains the placement visual at the arranged size of the element, and translates the element's `CornerRadius` to the
15-
backdrop clip so that rounded surfaces are respected as required.
14+
infrastructure required by `SystemBackdrop`. It creates the composition link a backdrop needs, keeps the placement
15+
visual sized to the arranged bounds, and applies the element's `CornerRadius` to the backdrop clip so rounded corners
16+
appear as expected.
1617

1718
## Goals
1819

19-
* Provide an intuitive, XAML-friendly way to place a system backdrop anywhere inside an app's visual tree.
20-
* Ensure the host handles connection, disconnection, and sizing so that apps only need to set a backdrop and place the
21-
element.
22-
* Allow apps to round the hosted backdrop without writing custom composition code.
20+
* Provide an intuitive, XAML-friendly way to place a system backdrop anywhere inside application's visual tree.
21+
* Handle connection, disconnection, and sizing so application only have to set a backdrop and position the element.
22+
* Allow to round the hosted backdrop without writing custom composition code.
2323

2424
## Non-goals
2525

26-
* Replace the window-level backdrop APIs on `Window` or `AppWindow`.
26+
* Supporting backdrop independently on all controls.
2727
* Provide a content container; `SystemBackdropHost` is purely a visual effect surface and does not host child content.
2828

29+
# Conceptual pages (How To)
30+
31+
The guidance in the below examples can be followed by developers for adopting
32+
`SystemBackdropHost`.
33+
2934
# API Pages
3035

36+
_(Each level-two section below maps to a docs.microsoft.com API page.)_
37+
3138
## SystemBackdropHost class
3239

40+
Use `SystemBackdropHost` to place a system-provided material anywhere within your XAML layout.
41+
3342
```csharp
3443
public sealed class SystemBackdropHost : FrameworkElement
3544
```
3645

37-
### Remarks
38-
39-
* The control is marked `[MUX_PREVIEW]`; the API may change before it is finalized.
40-
* When the element is loaded, it creates a `ContentExternalBackdropLink` and connects it to the assigned
41-
`SystemBackdrop`. When unloaded, or when the backdrop is removed, it releases composition resources and disconnects the backdrop.
42-
* The control does not render any visuals of its own. Place it behind content (for example as the first child in a `Grid`) to expose the backdrop surface.
43-
* The host only connects to a backdrop while it has a `XamlRoot`. If the element is not in the live tree, the backdrop will remain disconnected until it is loaded again.
44-
45-
### Example
46+
### Examples
4647

47-
XAML markup that layers a Acrylic material behind a page header with rounded corners and animation:
48+
You can place the host behind header content while keeping the rest of the page unchanged:
4849

4950
```xml
5051
<Grid x:Name="AnimatedGrid" Height="100" Width="100">
5152
<Grid.Resources>
5253
<Storyboard x:Name="SizeAnimation" RepeatBehavior="Forever">
5354
<DoubleAnimation Storyboard.TargetName="AnimatedGrid"
5455
Storyboard.TargetProperty="Width"
55-
From="100" To="200" Duration="0:0:2"
56+
From="100" To="200" Duration="0:0:2"
5657
RepeatBehavior="Forever"
5758
EnableDependentAnimation="True"
5859
AutoReverse="True"/>
@@ -73,44 +74,61 @@ XAML markup that layers a Acrylic material behind a page header with rounded cor
7374
</Grid>
7475
```
7576

77+
![Example of SystemBackdropHost with animation](images/Acrylic.gif)
7678

77-
The control can be configured in code behind as well like below:
79+
The same pattern works from code:
7880

79-
C#
8081
```csharp
81-
var backdropHost = new SystemBackdropHost
82+
var host = new SystemBackdropHost
8283
{
83-
SystemBackdrop = new DesktopAcrylicBackdrop(),
84-
CornerRadius = new CornerRadius(4),
84+
SystemBackdrop = new MicaBackdrop(),
85+
CornerRadius = new CornerRadius(12)
8586
};
86-
MainGrid.Children.Add(backdropHost);
87+
rootGrid.Children.Add(host);
8788
```
8889

89-
C++
9090
```cpp
91-
auto backdrop = winrt::Microsoft::UI::Xaml::Controls::SystemBackdropHost();
92-
backdrop.SystemBackdrop(winrt::Microsoft::UI::Xaml::Media::DesktopAcrylicBackdrop());
93-
backdrop.CornerRadius(winrt::Microsoft::UI::Xaml::CornerRadius({4}));
94-
AnimatedGrid().Children().Append(backdrop);
91+
winrt::Microsoft::UI::Xaml::Controls::SystemBackdropHost host;
92+
host.SystemBackdrop(winrt::Microsoft::UI::Xaml::Media::MicaBackdrop());
93+
host.CornerRadius(winrt::CornerRadius{ 12, 12, 12, 12 });
94+
rootGrid().Children().Append(host);
9595
```
9696
97+
In both snippets, `rootGrid` represents the panel that hosts the backdrop surface just behind your content.
98+
99+
### Remarks
100+
101+
* _Spec note: This type is currently marked `[MUX_PREVIEW]`; the API surface may still change before it is finalized._
102+
* The host creates a `ContentExternalBackdropLink` when it is loaded and a `SystemBackdrop` is assigned. When you
103+
remove the backdrop or the element unloads, the host releases the composition resources.
104+
* The element does not render visuals of its own. Place it behind other content (for example as the first child inside a
105+
panel) to expose the backdrop surface.
106+
* The host only connects to a backdrop while it has a `XamlRoot`. If the element is not in the live tree, the backdrop
107+
remains disconnected until it is loaded again.
108+
97109
## SystemBackdropHost.SystemBackdrop property
98110
99-
Gets or sets the `SystemBackdrop` instance that should render within this host. The default value is `null`.
111+
Gets or sets the `SystemBackdrop` instance that renders within this host. The default value is `null`.
100112
101-
* When set to a non-null systembackdrop and the host is loaded, the host invokes `SystemBackdrop.OnTargetConnected` with a `ContentExternalBackdropLink` that matches the arranged size of the element. The connection occurs lazily the next time the element is loaded if it is not already in the live tree.
102-
* Changing the property disconnects the previously assigned backdrop (via `OnTargetDisconnected`) before connecting the new value. Setting the property back to `null` releases the composition resources and removes the child visual from the element.
103-
* The property supports data binding and can be animated. Applications typically assign platform-provided backdrop types such as `MicaBackdrop`, `DesktopAcrylicBackdrop`, or custom subclasses of `SystemBackdrop`.
104-
* If the element does not yet have a `XamlRoot`, the connection is postponed until one becomes available.
113+
* When you assign a non-null backdrop and the host is loaded, it calls `SystemBackdrop.OnTargetConnected` with a
114+
`ContentExternalBackdropLink` that matches the element's arranged size. If the host is not yet loaded, the connection
115+
happens the next time it loads.
116+
* Changing the property disconnects the previous backdrop (through `OnTargetDisconnected`) before connecting the new
117+
value. Setting the property to `null` releases the composition resources and removes the child visual from the
118+
element.
119+
* You can data bind or animate this property. Typical values include `MicaBackdrop`, `DesktopAcrylicBackdrop`, or a
120+
custom subclass of `SystemBackdrop`.
121+
* If the host does not yet have a `XamlRoot`, the connection is postponed until one becomes available.
105122
106123
## SystemBackdropHost.CornerRadius property
107124
108-
Gets or sets the `CornerRadius` that should be applied to the hosted backdrop surface. The default value is
109-
`CornerRadius(0)`.
125+
Gets or sets the `CornerRadius` applied to the hosted backdrop surface. The default value is `CornerRadius(0)`.
110126
111-
* The host uses a `RectangleClip` applied to the backdrop's placement visual so that the rounded corner can be applied on all four edges.
112-
* Setting the property while the element is loaded immediately updates the clip. Setting it to `null` (from markup or a binding) clears the corner radius and restores square corners.
113-
* This property only affects the clip applied to the backdrop; it does not change layout or apply corner rounding to other child elements that may be layered on top.
127+
* The host applies a `RectangleClip` on the placement visual to achieve the rounded corners.
128+
* Updating the property while the element is loaded immediately refreshes the clip. Setting the property to `null` (for
129+
example through a binding) clears the stored corner radius and restores square corners.
130+
* This property only affects the backdrop clip. It does not change layout or round other content layered above the
131+
host.
114132
115133
# API Details
116134
@@ -131,3 +149,7 @@ namespace Microsoft.UI.Xaml.Controls
131149
}
132150
}
133151
```
152+
153+
# Appendix
154+
155+
Additional property for `SystemBackdropHost` to hold a child content can be considered at a later point based on requirement.

0 commit comments

Comments
 (0)