Skip to content

Instantly share code, notes, and snippets.

@jfversluis
Created March 8, 2023 18:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfversluis/226efd350fde6cceb28286ae8ef2327c to your computer and use it in GitHub Desktop.
Save jfversluis/226efd350fde6cceb28286ae8ef2327c to your computer and use it in GitHub Desktop.
Use the new Windows App SDK Backdrop API in .NET MAUI
using Microsoft.Extensions.Logging;
using Microsoft.Maui.LifecycleEvents;
#if WINDOWS
using Microsoft.UI.Xaml.Media;
#endif
namespace MauiApp1;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
#if WINDOWS
builder.ConfigureLifecycleEvents(events =>
{
// Make sure to add "using Microsoft.Maui.LifecycleEvents;" in the top of the file
events.AddWindows(windowsLifecycleBuilder =>
{
windowsLifecycleBuilder.OnWindowCreated(window =>
{
window.SystemBackdrop = new DesktopAcrylicBackdrop();
});
});
});
#endif
#if DEBUG
builder.Logging.AddDebug();
#endif
return builder.Build();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment