This project is read-only.

Navigation Module in Calcium

Feb 6, 2011 at 11:19 AM
Edited Apr 24, 2011 at 2:12 PM


  I  have just started learning this calcium framework and I am fan of it. Now I want to make a module that does the same exact thing that the "view" option does on the file menu (ie Launch the Modules if it is enabled in the module manager) but what is different is that this module will have icons and will work like a dashboard. This would be great  for better UI. Does anybody has done this already, or have an idea doing this??  If  yes please reply me back.  I want this module to be on the left region, workspace region. Populating the enabled the  icons or names of enabled module and launching the clicked module in the Working space region of the Calcium.



Apr 24, 2011 at 2:47 PM

Here is my latest since my last post few months back.


First My navigation module first loads in the WorkSpace Region. It has buttons for each modules (Custom modules as well as Calcium's Default modules). Here is a Grid inside <Gui:ViewControl>

        <ItemsControl ItemsSource="{Binding ApplicationModules}">
                    <WrapPanel Margin="7,7,7,7"  ItemHeight="125"  ItemWidth="125" />
                        <Button  Content="{Binding Path=ModuleName}" Margin="5,5,5,5" Width="75" Height="75" Click="Button_Click">
                                <SolidColorBrush />
                        <Label   Content="{Binding Path=ModuleName}" ClipToBounds="False" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"></Label>


 now here is the Code which is binded which is bound to the button. Since the number of button depends upon the number of items in ApplicationModules ObservableCollection, here is the Code how items gets added into the ApplicationModules

 foreach (var moduleInfo in knownModules)
                var module = new ApplicationModule
                    ModuleName = moduleInfo.ModuleName,
                    Enabled = true,
                   // ViewClass = moduleInfo.vie
                    //State = moduleInfo.InitializationMode == InitializationMode.WhenAvailable ? "Active" : "OnDemand"  /* TODO: Make localizable resource. */
                    State =  moduleInfo.State.ToString()


            var menuitems = from xxx in tempModules where xxx.State.ToString() != "NotStarted" && xxx.State.ToString() != "OnDemand" select xxx;
            foreach (var module in menuitems)

Upto this there is no problem. Fore every enabled module there is a button generated in Grid. Now my problem is loading the respective module depending upon the Button clicked. For that I have created the Button click event


private void Button_Click(object sender, RoutedEventArgs e)
            NavigationView view = new NavigationView();
            Button currentButton = sender as Button;
            string a;
            a = currentButton.Content.ToString();
            ArgumentValidator.AssertNotNullOrEmpty(defaultRegion, "regionName");
            ArgumentValidator.AssertNotNull(view, "view");
            var viewService = ServiceLocatorSingleton.Instance.GetInstance<IViewService>();
            string actualRegionName;
            viewService.ShowView(view, defaultRegion, true, out actualRegionName);
Now this Opens my Navigation module in the next tab just fine or any other module, but if the view object was dynamic depending on the string 'a'
in the above Button click event my navigation module would be complete. If a button with content 'Web browser' is clicked a would get a value 'Web browser' then the view object 
of web browser is passed to ShowView() function.
Please help in here, what am I doing wrong in here or what is missing in this or is there the better way of doing the same thing that I am trying to do in here.
This kind of module would be very nice and easy interface for any Calcium application. 
Apr 24, 2011 at 6:58 PM

As discussed on Twitter, a module can have more than one view. How will you handle this?  You also need to provide for modules without views.  What about multiple instances of views?  I'm not sure exactly how you are planning on people to use this... As a launcher or also shows active views?  What about views which you might not want shown?

You could register any views you want available in your new navigation during module initialisation and fire an event when someone presses a button. You would subscribe to the event within modules and react accordingly.  This would not work with built in modules without code changes.  You might also have issues in module loading order so keep that in mind too. Eg: you wouldn't be able to register a view with your nav service if the service isn't available at the time. 

How are you planning to assign the images?  Can you post a screenshot sometime as that might help further.

Above is my initial thoughts on your dilemma.  I shall keep thinking and report back if I have a better idea or you provide more info on exactly how you are expecting this to be used.  If you want it to behave exactly like the view menu, you could just clone the code and amend as necessary.

Is this something you are going to release to the community?

A button click event whilst will work, you may want to keep to the MVVM pattern and put your logic in your ViewModel.

Apr 25, 2011 at 1:50 AM


   I have done so because I got hint from the developer of the Calcium of DB Vaughan, to send a message from first module signaling the other to open the view and after looking through the source code of Calcium Sdk itself how it launches the module initially I tried to replicate that. And about that the multiple instances of views they are just part of bugs that are yet to handled because the primary function of module hasn't  finished.  But my question is will that be some kind of problem because it has browsers like functionality as you click in link it opens it in new tab without checking for anything.  Any way is Alright for me.

Secondly Yes I want to intend to behave exactly like view menu but with buttons instead of that drop down menu but I simply didn't know how to replicate that because I couldn't figure out what is bound to that menu.

I would love to release it with its source if it helps anybody and I think It will provide nice and easy Interface extention for Calcium.


Greetings and Regards