Note that there are some explanatory texts on larger screens.

plurals
  1. POTabControl with Regions PRISM
    text
    copied!<p>I am creating a shell. <code>XAML</code> which houses only a <code>TabControl</code>. I am trying to create new tabs on a button click event. With the code that I have written till now I am able to create new tabs on a button click event but the content of the Tab (a region) is only shown on the FIRST Tab and the new tabs that are created are empty. I.e. I am not able to show the same content (the region) in the newly created tabs...</p> <p><strong>Shell.XAML</strong></p> <pre><code>&lt;TabControl Name="MyTabs" Prism:RegionManager.RegionName="{x:Static inf:RegionConstants.MainRegion}"&gt; &lt;/TabControl&gt; </code></pre> <p><code>UserControl</code> that I wish to add to tabs:</p> <p><strong>MainControls.XAML</strong></p> <pre><code>&lt;UserControl&gt; &lt;Grid&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="*"/&gt; &lt;/Grid.RowDefinitions&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="Auto" /&gt; &lt;ColumnDefinition Width="Auto" /&gt; &lt;ColumnDefinition Width="*" /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Grid x:Name="LeftGrid" Grid.Row="0" Grid.Column="0" Prism:RegionManager.RegionName="{x:Static inf:RegionConstants.InputRegion}"&gt; &lt;GridSplitter&gt; &lt;Grid x:Name="RightGrid" Grid.Row="0" Grid.Column="0" Prism:RegionManager.RegionName="{x:Static inf:RegionConstants.OutputRegion}"&gt; &lt;/Grid&gt; &lt;/UserControl&gt; </code></pre> <p><strong>Function to Add Tab</strong></p> <pre><code>private void New_Tab(object sender, RoutedEventArgs e) { TabItem tab = new TabItem(); tab.Header = "New Tab"; tab.Content = new MainControls(); MyTabs.Items.Add(tab); } </code></pre> <p><strong>Module for Registering MainRegion</strong></p> <pre><code>class CollaboratedModule :IModule { private IUnityContainer container = default(IUnityContainer); private IRegionManager regionManager = default(IRegionManager); public CollaboratedModule(IUnityContainer container, IRegionManager regionManager) { this.container = container; this.regionManager = regionManager; } public void Initialize() { if (this.container != default(IUnityContainer) &amp;&amp; this.regionManager != default(IRegionManager)) { var IntergratedView = this.container.Resolve&lt;MainControls&gt;(); this.regionManager.AddToRegion(RegionConstants.MainRegion, IntergratedView); this.regionManager.Regions[RegionConstants.MainRegion].Activate(IntergratedView); } } } </code></pre> <p>Similarly i have created a Module for registering <code>InputRegion</code> and the <code>OutputRegion</code>. Can anyone let me know where is the issue in this code and how can I resolve it?</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