Altinet
  • Home
  • Blog
  • Contact





Navigation recipe for Caliburn Micro

On 06 Jan, 2011
Silverlight
By : Bruno Samardzic
With 7 Comments
Views : 13563

This time i have a real treat for you. I was kind of surprised there is no really good solution for navigation in caliburn framework (or i’m unaware of one). I decided to roll my own out with the following basic features:

1. Supports deeplinking
2. Easy setup
3. IOC agnostic

The solution comes with a really simple sample application which explains how you can set it up. To have it set up on your application you need to do following things:

1. Include the Caliburn.Micro.Navigation project
2. In the AppBootstraper part, you need to add the navigation conventions (see the AppBootstrapper of the sample app)
3. Register viewmodels with navigation names
4. In the shellView, replace ContentControl with Frame control and set CaliburnContentLoader as a contentLoader
5. Have the ShellViewModel inherit from NavigationConductor instead of Conductor

And i think that’s about it. To have DeepLinking enabled, use the INavigationAware interface on the particular screen.

I think that’s it, the sample app should be self explanatory if not:).
To grab the source head on to codeplex

Enjoy!



Previous Post Next Post 

About The Author

Bruno Samardzic


Number of Posts : 45
All Posts by : Bruno Samardzic

Comments ( 7 )

  • Yossi Jan 09 , 2011 at 4:00 pm / Reply

    Hi Bruno,

    It looks fantastic!
    Could you please add an example with an implementation of deep linking?

    Thanks,
    Yossi.

  • kagjes Jan 10 , 2011 at 6:48 am / Reply

    Hey Yossi, glad to be of help!
    You can find the sample source code on the link at the end of the post.
    http://cmnavigation.codeplex.com/SourceControl/list/changesets. The deep linking is also demonstrated there, you should try calling the page two with some varible after the addres, for instance
    %path #/PageTwoViewModel?id=46. It should write id=46 on the main page. You should be able to take it from there. If you need any further assistance i’ll be glad to help.

    • Yossi Jan 25 , 2011 at 1:12 pm / Reply

      Hi Bruno,

      How can you change the browser’s title according to your location?
      Of course with a custom title which doesn’t derive from the viewmodel’s name.

      Btw, I’ve put to use silverlight’s UriMapper and it’s working great, one thing you have to change is the condition NavigationConductor.cs (line 53), where you’ll have to extend it from “if (targetUri.GetNavigationName() != ActiveItem.GetNavigationName())” to check also for a change in the targetUri.Query so that if you navigate from /Main?Id=1 to /Main?Id=2 you’ll set again the QueryString property of the INavigationAware Screen you’re calling.

      Thanks,
      Yossi.

  • kagjes Feb 18 , 2011 at 1:44 pm / Reply

    Yea, i’ve done some refactoring in the meanwhile around the the whole navigation recipe which i didn’t have time to upload unfortunately, but it sounds quite similar to what you described. As for the title name, hmm, not quite there yet, but from top of my head, you should probably bind the page’s title property to some property of the viewmodel, it should be simple as that. Glad you found the recipe useful:)

  • Col Mar 13 , 2011 at 9:10 am / Reply

    I get this error:

    Could not load type ‘Caliburn.Micro.ConductorBaseWithActiveItem`1′ from assembly ‘Caliburn.Micro, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’.

    At:

    public LoadResult EndLoad(IAsyncResult asyncResult)
    {
    CaliburnLoaderAsyncResult result = (CaliburnLoaderAsyncResult)asyncResult;
    if (result.Error != null)
    {
    throw result.Error;
    }
    result.Complete(); <—- Error

  • Bruno Mar 13 , 2011 at 2:51 pm / Reply

    hmm, not sure what the trouble is. i did a few changes in the meanwhile, i’ll try and upload a new version tomorrow

    • Giuseppe Mar 27 , 2011 at 9:52 am / Reply

      Looking forward to the updated version.

      Also do you have an example on how you would wire this up with MEF instead of Autofac?


Leave a Comment

Click here to cancel reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>





Recent Posts

  • Angular vs React: round 2
  • Why programming is hard
  • Orchard Workflows, undocumented gem
  • The React Redux
  • React.js invoicing CRUD application, part 2: Description

Recent Comments

  • Angshuman on Animation for starred grid rows and columns using xaml
  • Advanced Excel Training in Lucknow on Angular vs React: round 2
  • Reginald Sophomore on My example of Angularjs directive
  • Slobodan on Angular and Breeze – story so far.
  • Bruno Samardzic on Reaction to Ember-forged Durandal Angularly Knocking out my Backbone, or my JS MVC framework research conclusion.

Contact

Altinet d.o.o.

OIB: 97429091194

Čulinečka cesta 146, Zagreb

Tel: +385 (1) 2946 819

Mob: +385 (98) 210 756

IBAN: HR4323400091110406470

Latest tweets