|
| 1 | +using Uno.Resizetizer; |
| 2 | + |
| 3 | +namespace MvuxListApp; |
| 4 | +public partial class App : Application |
| 5 | +{ |
| 6 | + /// <summary> |
| 7 | + /// Initializes the singleton application object. This is the first line of authored code |
| 8 | + /// executed, and as such is the logical equivalent of main() or WinMain(). |
| 9 | + /// </summary> |
| 10 | + public App() |
| 11 | + { |
| 12 | + this.InitializeComponent(); |
| 13 | + } |
| 14 | + |
| 15 | + protected Window? MainWindow { get; private set; } |
| 16 | + protected IHost? Host { get; private set; } |
| 17 | + |
| 18 | + protected async override void OnLaunched(LaunchActivatedEventArgs args) |
| 19 | + { |
| 20 | + var builder = this.CreateBuilder(args) |
| 21 | + // Add navigation support for toolkit controls such as TabBar and NavigationView |
| 22 | + .UseToolkitNavigation() |
| 23 | + .Configure(host => host |
| 24 | +#if DEBUG |
| 25 | + // Switch to Development environment when running in DEBUG |
| 26 | + .UseEnvironment(Environments.Development) |
| 27 | +#endif |
| 28 | + .UseLogging(configure: (context, logBuilder) => |
| 29 | + { |
| 30 | + // Configure log levels for different categories of logging |
| 31 | + logBuilder |
| 32 | + .SetMinimumLevel( |
| 33 | + context.HostingEnvironment.IsDevelopment() ? |
| 34 | + LogLevel.Information : |
| 35 | + LogLevel.Warning) |
| 36 | + |
| 37 | + // Default filters for core Uno Platform namespaces |
| 38 | + .CoreLogLevel(LogLevel.Warning); |
| 39 | + |
| 40 | + // Uno Platform namespace filter groups |
| 41 | + // Uncomment individual methods to see more detailed logging |
| 42 | + //// Generic Xaml events |
| 43 | + //logBuilder.XamlLogLevel(LogLevel.Debug); |
| 44 | + //// Layout specific messages |
| 45 | + //logBuilder.XamlLayoutLogLevel(LogLevel.Debug); |
| 46 | + //// Storage messages |
| 47 | + //logBuilder.StorageLogLevel(LogLevel.Debug); |
| 48 | + //// Binding related messages |
| 49 | + //logBuilder.XamlBindingLogLevel(LogLevel.Debug); |
| 50 | + //// Binder memory references tracking |
| 51 | + //logBuilder.BinderMemoryReferenceLogLevel(LogLevel.Debug); |
| 52 | + //// DevServer and HotReload related |
| 53 | + //logBuilder.HotReloadCoreLogLevel(LogLevel.Information); |
| 54 | + //// Debug JS interop |
| 55 | + //logBuilder.WebAssemblyLogLevel(LogLevel.Debug); |
| 56 | + |
| 57 | + }, enableUnoLogging: true) |
| 58 | + .UseConfiguration(configure: configBuilder => |
| 59 | + configBuilder |
| 60 | + .EmbeddedSource<App>() |
| 61 | + .Section<AppConfig>() |
| 62 | + ) |
| 63 | + .ConfigureServices((context, services) => |
| 64 | + { |
| 65 | + // TODO: Register your services |
| 66 | + //services.AddSingleton<IMyService, MyService>(); |
| 67 | + }) |
| 68 | + .UseNavigation(ReactiveViewModelMappings.ViewModelMappings, RegisterRoutes) |
| 69 | + ); |
| 70 | + MainWindow = builder.Window; |
| 71 | + |
| 72 | +#if DEBUG |
| 73 | + MainWindow.UseStudio(); |
| 74 | +#endif |
| 75 | + MainWindow.SetWindowIcon(); |
| 76 | + |
| 77 | + Host = await builder.NavigateAsync<Shell>(); |
| 78 | + } |
| 79 | + |
| 80 | + private static void RegisterRoutes(IViewRegistry views, IRouteRegistry routes) |
| 81 | + { |
| 82 | + views.Register( |
| 83 | + new ViewMap(ViewModel: typeof(ShellModel)), |
| 84 | + new ViewMap<MainPage, MainModel>(), |
| 85 | + new DataViewMap<SecondPage, SecondModel, Entity>() |
| 86 | + ); |
| 87 | + |
| 88 | + routes.Register( |
| 89 | + new RouteMap("", View: views.FindByViewModel<ShellModel>(), |
| 90 | + Nested: |
| 91 | + [ |
| 92 | + new ("Main", View: views.FindByViewModel<MainModel>(), IsDefault:true), |
| 93 | + new ("Second", View: views.FindByViewModel<SecondModel>()), |
| 94 | + ] |
| 95 | + ) |
| 96 | + ); |
| 97 | + } |
| 98 | +} |
0 commit comments