my name is Cristian and I've been working with Caliburn in several silverlight projects so I'm not that new to it. Recently I started working on a WinRT application in which I'm trying to use it but stumbled on a little issue.
First of all I'm going to try and give you some context: the application I'm working on is a media application in which I want to support media playback while the user is navigating throughout the application and also while the application is in the background.
From my experiments to properly achieve this I need a root page on which a "MediaElement" control must be placed and display all the other content inside of this root view. I should mention that I really wanted to use the NavigationService(FrameAdapter)
to navigate through my views. So what I ended up with was a view which has the media element and a "Frame" control inside it and modified the way the navigation service is created so that it will use this frame control. The problem now is that when
I try to navigate to a ViewModel using the "NavigateToViewModel<TViewModel>()" method, the view is properly detected but a corresponding ViewModel is not bound to it. I took a look over the code responsible for navigation and I isolated the
problem to this line of code:
var viewModel = ViewModelLocator.LocateForView(e.Content);
The LocateForView method will return the DataContext as the view model if one exists. In my case while navigating inside the ShellView all the views will have the ShellViewModel as the context as it is bound to the ShellView. To temporarily work around this
I created a custom NavigationService which uses the ViewModelLocator.LocateForViewType method instead.
My question is: am I doing things wrong ? Is it wrong to try and achieve view composition using frames from the perspective of the designers of Caliburn or was it just not taken into account?