WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit c327668

Browse files
author
Rashmi Thakur
committed
[ADD] Add new SystemBackdropHost Control Sample Page
1 parent 8847fa9 commit c327668

File tree

7 files changed

+169
-0
lines changed

7 files changed

+169
-0
lines changed

WinUIGallery/ContentIncludes.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@
239239
<Content Include="Samples\SampleCode\SystemBackdrops\SystemBackdropsSampleBackdropTypes_xaml.txt" />
240240
<Content Include="Samples\SampleCode\SystemBackdrops\SystemBackdropsSampleMicaController.txt" />
241241
<Content Include="Samples\SampleCode\SystemBackdrops\SystemBackdropsSampleDesktopAcrylicController.txt" />
242+
<Content Include="Samples\SampleCode\SystemBackdropHost\SystemBackdropHostAcrylic_xaml.txt" />
243+
<Content Include="Samples\SampleCode\SystemBackdropHost\SystemBackdropHostMica_xaml.txt" />
244+
<Content Include="Samples\SampleCode\SystemBackdropHost\SystemBackdropHostMicaAlt_xaml.txt" />
242245
<Content Include="Samples\SampleCode\TabView\TabViewBasicSample_cs.txt" />
243246
<Content Include="Samples\SampleCode\TabView\TabViewKeyboardAcceleratorSample_cs.txt" />
244247
<Content Include="Samples\SampleCode\TeachingTip\TeachingTipSample2_xaml.txt" />
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<!--
2+
//*********************************************************
3+
//
4+
// Copyright (c) Microsoft. All rights reserved.
5+
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6+
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7+
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8+
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9+
//
10+
//*********************************************************
11+
-->
12+
<Page x:Class="WinUIGallery.ControlPages.SystemBackdropHostPage"
13+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
14+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
15+
xmlns:controls="using:WinUIGallery.Controls"
16+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
17+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
18+
mc:Ignorable="d">
19+
<StackPanel>
20+
<controls:ControlExample x:Name="Example1" HeaderText="SystemBackdropHost Sample">
21+
<controls:ControlExample.Example>
22+
<Grid Width="300" Height="200" HorizontalAlignment="Center">
23+
<SystemBackdropHost x:Name="DynamicBackdropHost" CornerRadius="8">
24+
<SystemBackdropHost.SystemBackdrop>
25+
<DesktopAcrylicBackdrop />
26+
</SystemBackdropHost.SystemBackdrop>
27+
</SystemBackdropHost>
28+
<Button HorizontalAlignment="Center" VerticalAlignment="Center" Content="Click Me" />
29+
</Grid>
30+
</controls:ControlExample.Example>
31+
<controls:ControlExample.Options>
32+
<StackPanel Spacing="12">
33+
<ComboBox x:Name="BackdropTypeComboBox" Header="Backdrop Type" SelectedIndex="0" SelectionChanged="BackdropTypeComboBox_SelectionChanged">
34+
<ComboBoxItem Content="Acrylic" Tag="Acrylic" />
35+
<ComboBoxItem Content="Mica" Tag="Mica" />
36+
<ComboBoxItem Content="Mica Alt" Tag="MicaAlt" />
37+
</ComboBox>
38+
<Slider x:Name="CornerRadiusSlider" Header="Corner Radius" Maximum="50" Minimum="0" StepFrequency="1" Value="8" ValueChanged="CornerRadiusSlider_ValueChanged" />
39+
<TextBlock>
40+
<Run Text="Current Radius: " />
41+
<Run Text="{x:Bind CornerRadiusSlider.Value, Mode=OneWay}" />
42+
</TextBlock>
43+
</StackPanel>
44+
</controls:ControlExample.Options>
45+
<controls:ControlExample.XamlSource>
46+
SystemBackdropHost/SystemBackdropHostAcrylic_xaml.txt
47+
</controls:ControlExample.XamlSource>
48+
<controls:ControlExample.Substitutions>
49+
<controls:ControlExampleSubstitution Key="CornerRadius" Value="{x:Bind CornerRadiusSlider.Value, Mode=OneWay}" />
50+
</controls:ControlExample.Substitutions>
51+
</controls:ControlExample>
52+
</StackPanel>
53+
</Page>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using Microsoft.UI.Xaml;
5+
using Microsoft.UI.Xaml.Controls;
6+
using Microsoft.UI.Xaml.Media;
7+
8+
namespace WinUIGallery.ControlPages;
9+
10+
public sealed partial class SystemBackdropHostPage : Page
11+
{
12+
public SystemBackdropHostPage()
13+
{
14+
this.InitializeComponent();
15+
}
16+
17+
private void BackdropTypeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
18+
{
19+
if (DynamicBackdropHost == null || BackdropTypeComboBox == null)
20+
return;
21+
22+
var selectedItem = BackdropTypeComboBox.SelectedItem as ComboBoxItem;
23+
if (selectedItem == null)
24+
return;
25+
26+
string backdropType = selectedItem.Tag?.ToString() ?? "Acrylic";
27+
28+
// Update the SystemBackdrop based on selection
29+
if (backdropType == "Acrylic")
30+
{
31+
DynamicBackdropHost.SystemBackdrop = new DesktopAcrylicBackdrop();
32+
// Update the sample code source
33+
if (Example1 != null)
34+
{
35+
Example1.XamlSource = "SystemBackdropHost/SystemBackdropHostAcrylic_xaml.txt";
36+
}
37+
}
38+
else if (backdropType == "Mica")
39+
{
40+
DynamicBackdropHost.SystemBackdrop = new MicaBackdrop { Kind = Microsoft.UI.Composition.SystemBackdrops.MicaKind.Base };
41+
// Update the sample code source
42+
if (Example1 != null)
43+
{
44+
Example1.XamlSource = "SystemBackdropHost/SystemBackdropHostMica_xaml.txt";
45+
}
46+
}
47+
else if (backdropType == "MicaAlt")
48+
{
49+
DynamicBackdropHost.SystemBackdrop = new MicaBackdrop { Kind = Microsoft.UI.Composition.SystemBackdrops.MicaKind.BaseAlt };
50+
// Update the sample code source
51+
if (Example1 != null)
52+
{
53+
Example1.XamlSource = "SystemBackdropHost/SystemBackdropHostMicaAlt_xaml.txt";
54+
}
55+
}
56+
}
57+
58+
private void CornerRadiusSlider_ValueChanged(object sender, Microsoft.UI.Xaml.Controls.Primitives.RangeBaseValueChangedEventArgs e)
59+
{
60+
if (DynamicBackdropHost != null)
61+
{
62+
DynamicBackdropHost.CornerRadius = new CornerRadius(e.NewValue);
63+
}
64+
}
65+
}

WinUIGallery/Samples/Data/ControlInfoData.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2658,6 +2658,30 @@
26582658
"Uri": "https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.media.themeshadow"
26592659
}
26602660
]
2661+
},
2662+
{
2663+
"UniqueId": "SystemBackdropHost",
2664+
"Title": "SystemBackdropHost",
2665+
"BaseClasses": [
2666+
"Object",
2667+
"DependencyObject",
2668+
"UIElement",
2669+
"FrameworkElement",
2670+
"Control",
2671+
"ContentControl"
2672+
],
2673+
"ApiNamespace": "Microsoft.UI.Xaml.Controls",
2674+
"Subtitle": "A control to host system backdrop materials.",
2675+
"ImagePath": "ms-appx:///Assets/ControlImages/Acrylic.png",
2676+
"Description": "SystemBackdropHost allows you to apply system backdrop materials to specific UI elements.",
2677+
"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.",
2678+
"IsNew": true,
2679+
"Docs": [
2680+
{
2681+
"Title": "SystemBackdropHost - API",
2682+
"Uri": "https://learn.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.systembackdrophost"
2683+
}
2684+
]
26612685
}
26622686
]
26632687
},
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Grid Width="300" Height="200">
2+
<SystemBackdropHost CornerRadius="$(CornerRadius)">
3+
<SystemBackdropHost.SystemBackdrop>
4+
<DesktopAcrylicBackdrop />
5+
</SystemBackdropHost.SystemBackdrop>
6+
</SystemBackdropHost>
7+
<Button Content="Click Me" HorizontalAlignment="Center" VerticalAlignment="Center"/>
8+
</Grid>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Grid Width="300" Height="200">
2+
<SystemBackdropHost CornerRadius="$(CornerRadius)">
3+
<SystemBackdropHost.SystemBackdrop>
4+
<MicaBackdrop Kind="BaseAlt" />
5+
</SystemBackdropHost.SystemBackdrop>
6+
</SystemBackdropHost>
7+
<Button Content="Click Me" HorizontalAlignment="Center" VerticalAlignment="Center"/>
8+
</Grid>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Grid Width="300" Height="200">
2+
<SystemBackdropHost CornerRadius="$(CornerRadius)">
3+
<SystemBackdropHost.SystemBackdrop>
4+
<MicaBackdrop Kind="Base" />
5+
</SystemBackdropHost.SystemBackdrop>
6+
</SystemBackdropHost>
7+
<Button Content="Click Me" HorizontalAlignment="Center" VerticalAlignment="Center"/>
8+
</Grid>

0 commit comments

Comments
 (0)