dotnet new maui -n HelloMaui
public class Startup : IStartup
{
public void Configure(IAppHostBuilder appBuilder)
{
appBuilder
.UseMauiApp<App>();
}
}
public partial class App : Application
{
public override IWindow CreateWindow(IActivationState activationState)
{
return new MainWindow();
}
}
public class MainWindow : IWindow
{
public MainWindow()
{
Page = new MainPage();
}
public IPage Page { get; set; }
public IMauiContext MauiContext { get; set; }
}
public class Startup : IStartup
{
public void Configure(IAppHostBuilder appBuilder)
{
appBuilder
.UseMauiApp<App>()
.ConfigureLifecycleEvents(lifecycle => {
#if ANDROID
lifecycle.AddAndroid(d => {
d.OnBackPressed(activity => {
System.Diagnostics.Debug.WriteLine("Back button pressed!");
});
});
#endif
});
}
}
public class Startup : IStartup
{
public void Configure(IAppHostBuilder appBuilder)
{
appBuilder
.UseMauiApp<App>()
.ConfigureEssentials(essentials =>
{
essentials
.UseVersionTracking()
.UseMapServiceToken("YOUR-KEY-HERE");
});
}
}
public static IAppHostBuilder ConfigureEssentials(this IAppHostBuilder builder, Action<HostBuilderContext, IEssentialsBuilder> configureDelegate = null)
{
builder.ConfigureLifecycleEvents(life =>
{
#if __ANDROID__
Platform.Init(MauiApplication.Current);
life.AddAndroid(android => android
.OnRequestPermissionsResult((activity, requestCode, permissions, grantResults) =>
{
Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
})
.OnNewIntent((activity, intent) =>
{
Platform.OnNewIntent(intent);
})
.OnResume((activity) =>
{
Platform.OnResume();
}));
#elif __IOS__
life.AddiOS(ios => ios
.ContinueUserActivity((application, userActivity, completionHandler) =>
{
return Platform.ContinueUserActivity(application, userActivity, completionHandler);
})
.OpenUrl((application, url, options) =>
{
return Platform.OpenUrl(application, url, options);
})
.PerformActionForShortcutItem((application, shortcutItem, completionHandler) =>
{
Platform.PerformActionForShortcutItem(application, shortcutItem, completionHandler);
}));
#elif WINDOWS
life.AddWindows(windows => windows
.OnLaunched((application, args) =>
{
Platform.OnLaunched(args);
}));
#endif
});
if (configureDelegate != null)
builder.ConfigureServices<EssentialsBuilder>(configureDelegate);
return builder;
}
<Label
Text="Welcome to .NET MAUI!"
SemanticProperties.HeadingLevel="Level1"
FontSize="32"
HorizontalOptions="CenterAndExpand" />
<Label
Style="{DynamicResource Glyph}"
Text=""
SemanticProperties.Description="Heart" />
<Label
Text="Click the button. You know you want to!"
FontSize="18"
x:Name="CounterLabel"
HorizontalOptions="CenterAndExpand" />
<Button
Text="Click Me!"
Clicked="OnButtonClicked"
SemanticProperties.Hint="Counts the number of times you click"/>
欢迎光临 CSkin博客 (http://bbs.cskin.net/) | Powered by Discuz! X3.2 |