Created
February 25, 2022 13:32
-
-
Save codemonkey85/0f31491b7465318a4d3c0e18d0a8ae72 to your computer and use it in GitHub Desktop.
.NET MAUI AppAction Setup Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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