Viewlocator: Views not found outside external modules

Topics: UI Architecture
Feb 10, 2013 at 8:17 AM
Edited Feb 10, 2013 at 1:47 PM
I am working on a WPF app that loads its modules from dlls as lazy screens into a TransitionContentControl. Views for Viewmodels in the module are correctly shown when following the standard naming conventions. However, there are two problems:

1) The module itself uses external "widgets", Screens with views that are loaded from yet another dll.
[ImportMany(typeof(IWidget), AllowRecomposition = true)]
        public IEnumerable<ExportFactory<IWidget, IWidgetMetadata>> _widgets { get; set; }

<ContentControl x:Name="Navigator" cal:View.Model="{Binding Navigator}"/>
The property "Navigator" is called and in the first instance no view is found. But then it is called a second time and then the views are detected as I can see that the widget viewmodels have a view attached (OnViewAttached called) to them (ViewAware class), also the View itself has the ViewModel as its DataContext. However, they are not shown at the end, I also recognise that the "OnViewLoaded" is never called, instead the view "could not find view...". Where is the problem?

I have used a similar prototype app and added the Widgets project that produces the problem, however the Navigator property is called only once here and no view is found.

2) Another problem is that "cal:View.Context" does not seem to work in the modules, so subfolders in the View folder do not seem to be resolved.