Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>We do something similar, though we have the tab items already created (with no content) and show/hide as appropriate. When the tab item is selected, then we load the tab content.</p> <pre><code>private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.OriginalSource != sender) return; TabControl tabControl = (TabControl)sender; TabItem tabItem = (TabItem)tabControl.SelectedItem; if (!tabItem.HasContent) AddTabContent(tabItem); // This will cause a refresh once the content is loaded. else Refresh(tabItem); } private void AddTabContent(TabItem tabItem) { IOptimusPage page = tabItem.Tag as IOptimusPage; //This allows lazy loading of controls if (page != null) { if (!tabItem.HasContent) { CustomerEngagementUserControl control = page.GetControl(DataContext as CustomerEngagementUIObject, Services); tabItem.Content = control; } } } </code></pre> <p>The tab item content is specified in the tab item tag, using pages which are responsible for creating the content.</p> <pre><code>&lt;TabItem Header="Personal Background" Style="{StaticResource FirstBreadcrumbTabItem}" x:Name="PersonalBackgroundTab"&gt; &lt;TabItem.Tag&gt; &lt;Pages:FfnaPersonalBackgroundPage /&gt; &lt;/TabItem.Tag&gt; &lt;/TabItem&gt; </code></pre> <p>The page creates the control.</p> <pre><code>class FfnaPersonalBackgroundPage : IOptimusPage { #region IOptimusPage Members public CustomerEngagementUserControl GetControl(CustomerEngagementUIObject dataContext, CustomerEngagementServices services) { CustomerEngagementUserControl control = new FfnaPersonalBackgroundControl(); control.DataContext = dataContext; control.Services = services; return control; } #endregion } </code></pre> <p>You could use a similar technique to create your tab items on the fly.</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