Note that there are some explanatory texts on larger screens.

plurals
  1. POPRISM-MVVM, ItemsControl problem with View injection
    text
    copied!<p>I need to display multiple instances of a basketDetailsView.xaml within a region placed in basketView.xaml, but I'm getting the following errormessage when i debug my code:</p> <p>"An exception occurred while creating a region with name 'basketRegion'. The exception was: System.InvalidOperationException: ItemsControl's ItemsSource property is not empty. This control is being associated with a region, but the control is already bound to something else. If you did not explicitly set the control's ItemSource property, this exception may be caused by a change in the value of the inherited RegionManager attached property"</p> <p>The basketView XAML contains an ItemsControl tag defined like this </p> <pre><code>&lt;ItemsControl x:Name="basketItemsControl"cal:RegionManager.RegionName="basketRegion"/&gt; </code></pre> <p>The view also has a listbox where I can uncheck/check the BasketDetailsViews I want to look at:</p> <pre><code>&lt;ListBox x:Name="basketListBox" ItemsSource="{Binding basket}" MinWidth="200"&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;CheckBox commands:Checked1.Command="{Binding DataContext.CheckCommand,ElementName=basketListBox}" Content="{Binding basketName}" &gt;&lt;/CheckBox&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox </code></pre> <p>When I run without debugging it executes fine and I can pop in/out the different basketDetailsViews, but when debugging the above mentioned error shows. What Am i doing wrong?</p> <p>EDIT:</p> <pre><code>Public Sub AddCageDetailsView(ByVal BasketName As String) Dim basketRegion = _RegionManager.Regions("basketRegion") Dim view = _Container.Resolve(Of basketDetailsView)() Dim viewmodel = _Container.Resolve(Of basketDetailsViewModel)() view.ApplyModel(viewmodel) basketRegion.Add(view) End Sub </code></pre> <p>So basketRegion is the region in my ItemsControl as specified above. This region is supposed to hold my basketDetailsViews..</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