Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to wire up data context in modular application?
    primarykey
    data
    text
    <p>I am writing an application, WPF, using PRISM. I'm new so apologies if this question is poor form:</p> <p>I have a module that up to now has a user control for displaying a list of inspections. My module has entities written and a DbContext class to access DB. My question is where should this get initialsed and passed into my ViewModel???????</p> <p>Shell XAML</p> <pre><code>&lt;Window x:Class="ChargeMgm.Desktop.Shell" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:prism="http://www.codeplex.com/prism" Title="EMS" Height="350" Width="525"&gt; &lt;Grid&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="auto"/&gt; &lt;RowDefinition MinHeight="100"/&gt; &lt;RowDefinition/&gt; &lt;/Grid.RowDefinitions&gt; &lt;TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="Calibri" FontSize="16" Foreground="SteelBlue" Margin="5"&gt;Street Works Modules&lt;/TextBlock&gt; &lt;Border BorderThickness="1" BorderBrush="SteelBlue" CornerRadius="3" Grid.Row="1" Margin="5"&gt; &lt;ItemsControl prism:RegionManager.RegionName="MainRegion" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"/&gt; &lt;/Border&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre> <p>Bootstrapper class</p> <pre><code> class Bootstrapper : UnityBootstrapper { protected override System.Windows.DependencyObject CreateShell() { return new Shell(); } protected override void InitializeShell() { base.InitializeShell(); App.Current.MainWindow = (Window)this.Shell; App.Current.MainWindow.Show(); } protected override void ConfigureModuleCatalog() { base.ConfigureModuleCatalog(); ModuleCatalog moduleCatalog = (ModuleCatalog)this.ModuleCatalog; moduleCatalog.AddModule(typeof(DefectModule.DefectModule)); } } </code></pre> <p>Module</p> <pre><code>public class DefectModule : IModule { private readonly IRegionManager regionManager; private IUnityContainer container; public DefectModule(IUnityContainer container, IRegionManager regionManager) { this.regionManager = regionManager; this.container = container; } public void Initialize() { container.RegisterType&lt;IDefectsView, DefectsView&gt;(); container.RegisterType&lt;IDefectsViewModel, DefectsViewModel&gt;(); container.RegisterType&lt;IDefectContext, DefectContext&gt;(); var view = container.Resolve&lt;IDefectsView&gt;(); if(regionManager.Regions.ContainsRegionWithName("MainRegion")) { regionManager.Regions["MainRegion"].Add(view); //regionManager.RegisterViewWithRegion("MainRegion", typeof(IDefectsView)); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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