title: DEVEXPRESS MVVM: managing tabs in a DocumentGroup
body: <p>I'm working with the MVVM pattern, with C# in VS2013.</p>
  
  <p>I have a DocumentGroup in my project and a group of user control (xaml files) in a directory of my project. </p>
  
  <pre><code>&lt;dxd:DocumentGroup Name="documentcontainer" ItemHeight="3*" SelectedTabIndex="0" ItemsSource="{Binding tabsCollection}" AllowMove="False" AllowFloat="False" AllowDrag="False"&gt;
  
  &lt;/dxd:DocumentGroup&gt;
  </code></pre>
  
  <p>Im my viewModel there is the define of tabsCollection:</p>
  
  <pre><code>    private ObservableCollection&lt;DocumentPanel&gt; p_tabsCollection;
      public ObservableCollection&lt;DocumentPanel&gt; tabsCollection
      {
          get { return p_tabsCollection; }
          set
          {
              p_tabsCollection = value;
              base.RaisePropertyChangedEvent("tabsCollection");
          }
  
      }
  
      private void Initialize() {
          DocumentPanel t = new DocumentPanel( );
          t.Content = Application.LoadComponent(new Uri("View/UC/ucImpianti.xaml", UriKind.Relative)); ;
          p_tabsCollection.Add(t);
      }
  </code></pre>
  
  <ol>
  <li>is the type of tabsCollection correct?</li>
  <li>how can I insert my user control (xaml file) in the documentPanel? (if the type is correct)</li>
  </ol>
  
  <p>I want create some tabs populated with the user control. From my menu, different voices must open different "usercontrol in tabs", so at the start-time there is no tabs: they are created at runtime, when user clicks on the menu.</p>
  
  <p>UPDATED CODE: now it seems correct, but it generates an error/exception when starts..</p>
  
  <hr>
  
  <p><strong>UPDATE-->SOLUTION</strong></p>
  
  <p>In this way it works:</p>
  
  <pre><code>&lt;dxd:DocumentGroup Name="documentcontainer" ItemHeight="3*" ItemsSource="{Binding tabsCollection}" AllowDrag="False" AllowMove="False" AllowSplitters="False" AllowSizing="False" AllowFloat="False" ClosingBehavior="ImmediatelyRemove" SelectedTabIndex="{Binding SelectedDocumentIndex}" &gt;
      &lt;dxd:DocumentGroup.ItemStyle&gt;
          &lt;Style TargetType="dxd:DocumentPanel"&gt;
              &lt;Setter Property="CloseCommand" Value="{Binding CloseCommand}" /&gt;
          &lt;/Style&gt;
      &lt;/dxd:DocumentGroup.ItemStyle&gt;
  &lt;/dxd:DocumentGroup&gt;
  </code></pre>
  
  <p>While CloseCommand is the same I posted when I asked this question. The key-to-solution was in the xaml.</p>