예제 #1
0
        private void ShowShell(ContainerBuilder builder)
        {
            builder.RegisterType <MainWindow>()
            .SingleInstance()
            .OnActivated(e =>
            {
                var shell = e.Instance;

                var regionContainer  = e.Context.Resolve <IRegionContainer>();
                var tabRegion        = regionContainer.GetRegion <Regions.TabRegion>();
                var viewFactory      = e.Context.Resolve <ICreateView>();
                var tabRegionAdapter = Scope.From(new TabRegionAdapter(viewFactory, shell.TabRegion));
                tabRegion.Adapt(tabRegionAdapter);

                var menuBuilder = new MenuBuilder(shell.MenuRegion);
                menuBuilder.AddMenuItem("Add", () => AddNewView(tabRegion));
                menuBuilder.AddMenuItems("GroupOfItems", GetMenuCommands());

                var parentMenuItem = CreateParentMenuCommand();
                menuBuilder.AddMenuItem(parentMenuItem);
                menuBuilder.AddMenuItems(parentMenuItem, GetMenuCommands());

                menuBuilder.AddMenuItems(parentMenuItem, new MenuCommand()
                {
                    Title = "Added later"
                });

                menuBuilder.AddMenuItem("Other", () => tabRegion.RequestNavigate <OtherViewModel>(NavigationParameters.UserNavigation));
                menuBuilder.AddMenuItem("Close all", () => tabRegion.CloseAll());
            });

            _container = builder.Build();

            Application.Current.MainWindow = _container.Resolve <MainWindow>();
            Application.Current.MainWindow.Show();
        }