Note that there are some explanatory texts on larger screens.

plurals
  1. POXAML And Dependency Injection
    primarykey
    data
    text
    <p>I have a dialog box that is created using MEF and it has an exposed member in its View Model called 'Container' which is a reference to the CompositionContainer. Inside that dialog box is a drop down combobox that has a selection of customers. I want to select a customer from a list that is created from the shared data model. My dialog looks like this:</p> <pre><code>&lt;Window x:Class="MyNamespace.MyDialog" xmlns:common="http://schemas.teraque.com/common" ShowInTaskbar="False" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&gt; &lt;Grid Margin="4"&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition/&gt; &lt;RowDefinition/&gt; &lt;/Grid.RowDefinitions&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition /&gt; &lt;ColumnDefinition /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;common:ProductComboBox Grid.Row="1" Grid.Column="1"/&gt; &lt;TextBlock Text="Product" Grid.Row="0" Grid.Column="0"/&gt; &lt;common:CustomerComboBox Grid.Row="1" Grid.Column="1"/&gt; &lt;TextBlock Text="Customer" Grid.Row="1" Grid.Column="0"/&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre> <p>So how do we go about passing along the DI composition container to the Product or Customer combo boxes so they can query the shared services for the product and customer data? I've toyed around with the idea of referencing the container from the parent view model:</p> <pre><code>&lt;common:CustomerComboBox Container="{Binding Container}" Grid.Row="1" Grid.Column="1"/&gt; </code></pre> <p>Is there a better way?</p>
    singulars
    1. This table or related slice is empty.
    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.
    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