Skip to content

Instantly share code, notes, and snippets.

@codemonkey85
Created February 25, 2022 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codemonkey85/0f31491b7465318a4d3c0e18d0a8ae72 to your computer and use it in GitHub Desktop.
Save codemonkey85/0f31491b7465318a4d3c0e18d0a8ae72 to your computer and use it in GitHub Desktop.
.NET MAUI AppAction Setup Example
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureEssentials(essentials =>
{
foreach (var appAction in new AppAction[]
{
new ("AppAction1", "App Action 1"),
new ("AppAction2", "App Action 2"),
new ("AppAction3", "App Action 3"),
new ("AppAction4", "App Action 4"),
})
{
essentials.AddAppAction(appAction);
}
essentials.OnAppAction(/*async */(AppAction appAction) =>
{
switch (appAction.Id)
{
case "AppAction1":
// do stuff 1
break;
case "AppAction2":
// do stuff 2
break;
case "AppAction3":
// do stuff 3
break;
case "AppAction4":
// do stuff 4
break;
default:
break;
}
});
})
.ConfigureFonts(fonts => fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"));
return builder.Build();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment