MUI + Caliburn.Micro Navigation

Apr 9, 2014 at 1:18 AM
Edited Apr 9, 2014 at 11:43 AM

Question

Hi,

In my current project I am using MUI, Caliburn.Micro & Ninject. But I have some issues:

1) How can I show WarehouseProductCategoriesPageViewModel from ShellPageViewModel from code?
        public ShellPageViewModel()
        {
            // TODO: Instance of WarehouseProductCategoriesPageViewModel is created but View is not showed.
            ActivateItem(new WarehouseProductCategoriesPageViewModel());            
        }
2) How can I navigate to UpdateCategoryPageViewModel from WarehouseProductCategories?
    public class WarehouseProductCategoriesPageViewModel : Screen
    {       
        // TODO: How navigate to Update Categoy Page?       
        public void GoToUpdateCategoryPage()
        {
            // Some code...
            // Navigation to Update Category Page
        }
    }
P.S. All questions are written in code.

I'll be very thankful to somebody who can help me.

Best Regards,
Serhiy

Source Code

    APPLICATION BOOTSTRAPPER

    public class AppBootstrapper : BootstrapperBase
    {
        private IKernel _kernel;
        public AppBootstrapper()
        {
            Start();
        }

        protected override void OnStartup(object sender, System.Windows.StartupEventArgs e)
        {
            DisplayRootViewFor<IShellPage>();
        }

        private void ConfigureConvensions()
        {
            var tmc = new TypeMappingConfiguration
            {
                DefaultSubNamespaceForViewModels = "Pages",
            };

            ViewLocator.ConfigureTypeMappings(tmc);
            ViewModelLocator.ConfigureTypeMappings(tmc);
        }

        private void ConfigureCompositionRoot()
        {
            _kernel = new StandardKernel();
            _kernel.Bind<IWindowManager>().To<WindowManager>().InSingletonScope();
            _kernel.Bind<IEventAggregator>().To<EventAggregator>().InSingletonScope();
            _kernel.Bind<IShellPage>().To<ShellPageViewModel>().InSingletonScope();
        }

        protected override void Configure()
        {
            ConfigureConvensions();
            ConfigureCompositionRoot();
        }

        protected override object GetInstance(Type service, string key)
        {
            Contract.Requires<ArgumentNullException>(service.IsNotNull());

            return _kernel.Get(service);
        }

        protected override IEnumerable<object> GetAllInstances(Type service)
        {
            return _kernel.GetAll(service);
        }

        protected override void BuildUp(object instance)
        {
            Contract.Requires<ArgumentNullException>(instance.IsNotNull());

            _kernel.Inject(instance);
        }

        protected override void OnExit(object sender, EventArgs e)
        {
            if (_kernel.IsNotNull())
                _kernel.Dispose();

            base.OnExit(sender, e);
        }
    }   

    
    SHELL PAGE VIEWMODEL
    
    public interface IShellPage { }

    public class ShellPageViewModel : Conductor<IScreen>.Collection.OneActive, IShellPage
    {
        public ShellPageViewModel()
        {
            // TODO: Instance of WarehouseProductCategoriesPageViewModel is created but View is not showed.
            ActivateItem(new WarehouseProductCategoriesPageViewModel());            
        }
    }
    
    SHELL PAGE VIEW

    <mui:ModernWindow x:Class="Haircut.Desktop.Views.ShellPageView"        
                  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"                    
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"                          
                  xmlns:mui="http://firstfloorsoftware.com/ModernUI"        
                  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"        
                  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"             
                  mc:Ignorable="d"                          
                  ContentLoader="{StaticResource CaliburnContentLoader}">            
        <mui:ModernWindow.MenuLinkGroups>                
            <mui:LinkGroup DisplayName="Warehouse">            
                <mui:LinkGroup.Links>                
                    <mui:Link DisplayName="Product categories" Source="../Views/Warehouse/WarehouseProductCategoriesPageView.xaml" />
                </mui:LinkGroup.Links>
            </mui:LinkGroup>
        </mui:ModernWindow.MenuLinkGroups>        
    </mui:ModernWindow>


    WAREHOUSE PRODUCT CATEGORIES PAGE VIEWMODEL 
    
    public class WarehouseProductCategoriesPageViewModel : Screen
    {       
        // TODO: How navigate to Update Categoy Page?       
        public void GoToUpdateCategoryPage()
        {
            // Some code...
            // Navigation to Update Category Page
        }
    }