Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions WinUIGallery/ContentIncludes.props
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@
<Content Include="Samples\SampleCode\SystemBackdrops\SystemBackdropsSampleBackdropTypes_xaml.txt" />
<Content Include="Samples\SampleCode\SystemBackdrops\SystemBackdropsSampleMicaController.txt" />
<Content Include="Samples\SampleCode\SystemBackdrops\SystemBackdropsSampleDesktopAcrylicController.txt" />
<Content Include="Samples\SampleCode\SystemBackdropHost\SystemBackdropHostAcrylic_xaml.txt" />
<Content Include="Samples\SampleCode\SystemBackdropHost\SystemBackdropHostMica_xaml.txt" />
<Content Include="Samples\SampleCode\SystemBackdropHost\SystemBackdropHostMicaAlt_xaml.txt" />
<Content Include="Samples\SampleCode\TabView\TabViewBasicSample_cs.txt" />
<Content Include="Samples\SampleCode\TabView\TabViewKeyboardAcceleratorSample_cs.txt" />
<Content Include="Samples\SampleCode\TeachingTip\TeachingTipSample2_xaml.txt" />
Expand Down
53 changes: 53 additions & 0 deletions WinUIGallery/Samples/ControlPages/SystemBackdropHostPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!--
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
-->
<Page x:Class="WinUIGallery.ControlPages.SystemBackdropHostPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:WinUIGallery.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<StackPanel>
<controls:ControlExample x:Name="Example1" HeaderText="SystemBackdropHost Sample">
<controls:ControlExample.Example>
<Grid Width="300" Height="200" HorizontalAlignment="Center">
<SystemBackdropHost x:Name="DynamicBackdropHost" CornerRadius="8">
<SystemBackdropHost.SystemBackdrop>
<DesktopAcrylicBackdrop />
</SystemBackdropHost.SystemBackdrop>
</SystemBackdropHost>
<Button HorizontalAlignment="Center" VerticalAlignment="Center" Content="Click Me" />
</Grid>
</controls:ControlExample.Example>
<controls:ControlExample.Options>
<StackPanel Spacing="12">
<ComboBox x:Name="BackdropTypeComboBox" Header="Backdrop Type" SelectedIndex="0" SelectionChanged="BackdropTypeComboBox_SelectionChanged">
<ComboBoxItem Content="Acrylic" Tag="Acrylic" />
<ComboBoxItem Content="Mica" Tag="Mica" />
<ComboBoxItem Content="Mica Alt" Tag="MicaAlt" />
</ComboBox>
<Slider x:Name="CornerRadiusSlider" Header="Corner Radius" Maximum="50" Minimum="0" StepFrequency="1" Value="8" ValueChanged="CornerRadiusSlider_ValueChanged" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<Slider x:Name="CornerRadiusSlider" Header="Corner Radius" Maximum="50" Minimum="0" StepFrequency="1" Value="8" ValueChanged="CornerRadiusSlider_ValueChanged" />
<Slider x:Name="CornerRadiusSlider" Header="Corner radius" Maximum="50" Minimum="0" StepFrequency="1" Value="8" ValueChanged="CornerRadiusSlider_ValueChanged" />

<TextBlock>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of simplicity, do we need to plot the value? Why not just the slider?

<Run Text="Current Radius: " />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<Run Text="Current Radius: " />
<Run Text="Current radius: " />

<Run Text="{x:Bind CornerRadiusSlider.Value, Mode=OneWay}" />
</TextBlock>
</StackPanel>
</controls:ControlExample.Options>
<controls:ControlExample.XamlSource>
SystemBackdropHost/SystemBackdropHostAcrylic_xaml.txt
</controls:ControlExample.XamlSource>
<controls:ControlExample.Substitutions>
<controls:ControlExampleSubstitution Key="CornerRadius" Value="{x:Bind CornerRadiusSlider.Value, Mode=OneWay}" />
</controls:ControlExample.Substitutions>
</controls:ControlExample>
</StackPanel>
</Page>
65 changes: 65 additions & 0 deletions WinUIGallery/Samples/ControlPages/SystemBackdropHostPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media;

namespace WinUIGallery.ControlPages;

public sealed partial class SystemBackdropHostPage : Page
{
public SystemBackdropHostPage()
{
this.InitializeComponent();
}

private void BackdropTypeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (DynamicBackdropHost == null || BackdropTypeComboBox == null)
return;

var selectedItem = BackdropTypeComboBox.SelectedItem as ComboBoxItem;
if (selectedItem == null)
return;

string backdropType = selectedItem.Tag?.ToString() ?? "Acrylic";

// Update the SystemBackdrop based on selection
if (backdropType == "Acrylic")
{
DynamicBackdropHost.SystemBackdrop = new DesktopAcrylicBackdrop();
// Update the sample code source
if (Example1 != null)
{
Example1.XamlSource = "SystemBackdropHost/SystemBackdropHostAcrylic_xaml.txt";
}
}
else if (backdropType == "Mica")
{
DynamicBackdropHost.SystemBackdrop = new MicaBackdrop { Kind = Microsoft.UI.Composition.SystemBackdrops.MicaKind.Base };
// Update the sample code source
if (Example1 != null)
{
Example1.XamlSource = "SystemBackdropHost/SystemBackdropHostMica_xaml.txt";
}
}
else if (backdropType == "MicaAlt")
{
DynamicBackdropHost.SystemBackdrop = new MicaBackdrop { Kind = Microsoft.UI.Composition.SystemBackdrops.MicaKind.BaseAlt };
// Update the sample code source
if (Example1 != null)
{
Example1.XamlSource = "SystemBackdropHost/SystemBackdropHostMicaAlt_xaml.txt";
}
}
}

private void CornerRadiusSlider_ValueChanged(object sender, Microsoft.UI.Xaml.Controls.Primitives.RangeBaseValueChangedEventArgs e)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the code cleaner and more consistent with the rest of the file. 🙂

Suggested change
private void CornerRadiusSlider_ValueChanged(object sender, Microsoft.UI.Xaml.Controls.Primitives.RangeBaseValueChangedEventArgs e)
private void CornerRadiusSlider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)

{
if (DynamicBackdropHost != null)
{
DynamicBackdropHost.CornerRadius = new CornerRadius(e.NewValue);
}
}
}
24 changes: 24 additions & 0 deletions WinUIGallery/Samples/Data/ControlInfoData.json
Original file line number Diff line number Diff line change
Expand Up @@ -2658,6 +2658,30 @@
"Uri": "https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.media.themeshadow"
}
]
},
{
"UniqueId": "SystemBackdropHost",
"Title": "SystemBackdropHost",
"BaseClasses": [
"Object",
"DependencyObject",
"UIElement",
"FrameworkElement",
"Control",
"ContentControl"
],
"ApiNamespace": "Microsoft.UI.Xaml.Controls",
"Subtitle": "A control to host system backdrop materials.",
"ImagePath": "ms-appx:///Assets/ControlImages/Acrylic.png",
"Description": "SystemBackdropHost allows you to apply system backdrop materials to specific UI elements.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be better to mention 'specific area inside the UI tree' as we are not applying backdrop directly to ui elements

"Description": "SystemBackdropHost is developed to enable seamless Acrylic effects for individual surfaces and controls in WinUI3 apps. This control allows developers to easily apply system backdrops (like Acrylic and Mica) anywhere in their app UI.",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SystemBackdropHost enables applying Mica and Acrylic to individual UI elements within an app experience, extending these materials beyond the window background for more flexible and immersive designs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: For consistency, use "WinUI 3" instead of "WinUI3".

"IsNew": true,
"Docs": [
{
"Title": "SystemBackdropHost - API",
"Uri": "https://learn.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.systembackdrophost"
}
]
}
]
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Grid Width="300" Height="200">
<SystemBackdropHost CornerRadius="$(CornerRadius)">
<SystemBackdropHost.SystemBackdrop>
<DesktopAcrylicBackdrop />
</SystemBackdropHost.SystemBackdrop>
</SystemBackdropHost>
<Button Content="Click Me" HorizontalAlignment="Center" VerticalAlignment="Center"/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<Button Content="Click Me" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<Button Content="Button" HorizontalAlignment="Center" VerticalAlignment="Center"/>

</Grid>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Grid Width="300" Height="200">
<SystemBackdropHost CornerRadius="$(CornerRadius)">
<SystemBackdropHost.SystemBackdrop>
<MicaBackdrop Kind="BaseAlt" />
</SystemBackdropHost.SystemBackdrop>
</SystemBackdropHost>
<Button Content="Click Me" HorizontalAlignment="Center" VerticalAlignment="Center"/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<Button Content="Click Me" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<Button Content="Button" HorizontalAlignment="Center" VerticalAlignment="Center"/>

</Grid>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Grid Width="300" Height="200">
<SystemBackdropHost CornerRadius="$(CornerRadius)">
<SystemBackdropHost.SystemBackdrop>
<MicaBackdrop Kind="Base" />
</SystemBackdropHost.SystemBackdrop>
</SystemBackdropHost>
<Button Content="Click Me" HorizontalAlignment="Center" VerticalAlignment="Center"/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<Button Content="Click Me" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<Button Content="Button" HorizontalAlignment="Center" VerticalAlignment="Center"/>

</Grid>
Loading