Note that there are some explanatory texts on larger screens.

plurals
  1. POComposite WPF (Prism) module resource data templates
    text
    copied!<p>Given that I have a shell application and a couple of separate module projects using Microsoft CompoisteWPF (Prism v2)...</p> <p>On receiving a command, a module creates a new ViewModel and adds it to a region through the region manager.</p> <pre><code>var viewModel = _container.Resolve&lt;IMyViewModel&gt;(); _regionManager.Regions[RegionNames.ShellMainRegion].Add(viewModel); </code></pre> <p>I thought that I could then create a resource dictionary within the module and set up a data template to display a view for the view model type that was loaded (see below xaml). But when the view model is added to the view, all I get is the view models namespace printed out.</p> <pre><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:vm="clr-namespace:Modules.Module1.ViewModels" xmlns:vw="clr-namespace:Modules.Module1.Views" &gt; &lt;DataTemplate DataType="{x:Type vm:MyViewModel}"&gt; &lt;vw:MyView /&gt; &lt;/DataTemplate&gt; &lt;/ResourceDictionary&gt; </code></pre> <p>Edit:</p> <p>I can get it to work by adding to the App.xaml</p> <pre><code>&lt;Application.Resources&gt; &lt;ResourceDictionary.MergedDictionaries&gt; &lt;ResourceDictionary Source="pack://application:,,,/Module1;component/Module1Resources.xaml"/&gt; &lt;ResourceDictionary Source="pack://application:,,,/Module2;component/Module2Resources.xaml"/&gt; &lt;/ResourceDictionary.MergedDictionaries&gt; &lt;/Application.Resources&gt; </code></pre> <p>Which is fine, but it means that as new modules are created, the App.xaml file needs to be added to. What I'm looking for is a way for modules, as they load to dynamically add to the the Application.Resources. Is this possible?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload