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!
Yossi Jan 09 , 2011 at 4:00 pm /
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 /
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 /
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 /
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 /
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 /
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 /
Looking forward to the updated version.
Also do you have an example on how you would wire this up with MEF instead of Autofac?