Ejemplo n.º 1
0
        public App()
        {
            var host = Host
                       .CreateDefaultBuilder()
                       .ConfigureServices(services =>
            {
                services.UseMicrosoftDependencyResolver();
                var resolver = Locator.CurrentMutable;
                resolver.InitializeSplat();
                resolver.InitializeReactiveUI();


                DependencyBuilder.GetServices(services);
            })
                       .ConfigureLogging(loggingBuilder =>
            {
                loggingBuilder.AddSplat();
            })
                       .UseEnvironment(Environments.Development)
                       .Build();

            AssemblyHelper
            .GetSolutionAssemblies()
            .ToList()
            .ForEach(Locator.CurrentMutable.RegisterViewsForViewModels);

            // https://stackoverflow.com/questions/431940/how-to-set-default-wpf-window-style-in-app-xaml
            FrameworkElement.StyleProperty.OverrideMetadata(typeof(Window), new FrameworkPropertyMetadata
            {
                DefaultValue = Application.Current.FindResource(typeof(Window))
            });
        }
Ejemplo n.º 2
0
        public App()
        {
            var host = Host
                       .CreateDefaultBuilder()
                       .ConfigureServices(services =>
            {
                services.UseMicrosoftDependencyResolver();
                var resolver = Locator.CurrentMutable;
                resolver.InitializeSplat();
                resolver.InitializeReactiveUI();


                DependencyBuilder.GetServices(services);
            })
                       .ConfigureLogging(loggingBuilder =>
            {
                loggingBuilder.AddSplat();
            })
                       .UseEnvironment(Environments.Development)
                       .Build();

            Container = host.Services;
            //Container.UseMicrosoftDependencyResolver();

            Locator.CurrentMutable.RegisterViewsForViewModels(Assembly.GetExecutingAssembly());


            var value = Container.GetRequiredService <IMain>();

            new Window()
            {
                Title   = "TTC Tester",
                Content = new ViewModelViewHost()
                {
                    ViewModel = value,
                    VerticalContentAlignment   = VerticalAlignment.Stretch,
                    HorizontalContentAlignment = HorizontalAlignment.Stretch
                },
                VerticalContentAlignment   = VerticalAlignment.Stretch,
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment          = VerticalAlignment.Stretch,
                HorizontalAlignment        = HorizontalAlignment.Stretch,
            }.Show();
        }