Yet another simple MVVM library for Windows Phone.
Was started as an experiment back in time when there was only one way to perform navigation in WP:
NavigationService.Navigate(new Uri("/SecondPage.xaml", UriKind.Relative));
Obviously this is horrible: it's all string
based, no types and compile time checks. We also had to manually construct query string.
Nowadays things has changed and we can navigate to strongly typed Page
:
Frame.Navigate(typeof(SecondPage), param);
Much better now, isn't it?
- Compile time checks
- Parameters as
objects
, not asstrings
Still feels not very clean for me. Typically navigation is initialized from ViewMovel
, so you have to bring the knowlege about UI into your VM.
This library is an attempt to invert this dependency.
You can annotate your view with [DependsOnViewModel]
attribute, so that NavigationService
can discover and bind all Views
to ViewModels
.
NavigationService.NavigateTo<Page1ViewModel, Data>(new Data{Id = 1, Value = "value"});
That gives you better separation. View models can 'live' in separate assembly and have no references to views at all.