Loading...
Loading...
Create and manage WPF TabControl (TabControlExt) components for organizing content into tabs. Use this skill when users need to implement tabbed interfaces, manage tab selection, configure close buttons, handle tab interactions (clicking, keyboard navigation), customize tab appearance (orientation, placement), or bind tab data. Covers tab creation via XAML/C#, tab item management, event handling, context menus, drag-and-drop reordering, and theming.
npx skill4agent add syncfusion/wpf-ui-components-skills syncfusion-wpf-tabcontrolTabControl<Window x:Class="TabControlApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
Title="TabControl Example" Height="450" Width="800">
<Grid>
<syncfusion:TabControlExt Name="tabControl" Height="100" Width="280">
<syncfusion:TabItemExt Header="Tab 1">
<TextBlock Text="Content of Tab 1" />
</syncfusion:TabItemExt>
<syncfusion:TabItemExt Header="Tab 2">
<TextBlock Text="Content of Tab 2" />
</syncfusion:TabItemExt>
<syncfusion:TabItemExt Header="Tab 3">
<TextBlock Text="Content of Tab 3" />
</syncfusion:TabItemExt>
</syncfusion:TabControlExt>
</Grid>
</Window>using Syncfusion.Windows.Tools.Controls;
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
// Create TabControl instance
TabControlExt tabControlExt = new TabControlExt();
tabControlExt.Height = 100;
tabControlExt.Width = 280;
// Create and add TabItems
TabItemExt tabItem1 = new TabItemExt()
{
Header = "Tab 1",
Content = new TextBlock() { Text = "Content of Tab 1" }
};
TabItemExt tabItem2 = new TabItemExt()
{
Header = "Tab 2",
Content = new TextBlock() { Text = "Content of Tab 2" }
};
tabControlExt.Items.Add(tabItem1);
tabControlExt.Items.Add(tabItem2);
this.Content = tabControlExt;
}
}// Handle tab selection changes
tabControl.SelectedItemChangedEvent += TabControl_SelectedItemChangedEvent;
private void TabControl_SelectedItemChangedEvent(object sender, SelectedItemChangedEventArgs e)
{
var newTabItem = e.NewSelectedItem.Header;
var oldTabItem = e.OldSelectedItem?.Header ?? "None";
MessageBox.Show($"Changed from {oldTabItem} to {newTabItem}");
}<!-- Enable close buttons on both TabControl and TabItems -->
<syncfusion:TabControlExt CloseButtonType="Both" Name="tabControl">
<syncfusion:TabItemExt Header="Tab 1" />
<syncfusion:TabItemExt Header="Tab 2" CanClose="False" />
</syncfusion:TabControlExt><!-- Position tabs at the bottom -->
<syncfusion:TabControlExt TabStripPlacement="Bottom" Name="tabControl">
<syncfusion:TabItemExt Header="Tab 1" />
<syncfusion:TabItemExt Header="Tab 2" />
</syncfusion:TabControlExt><syncfusion:TabControlExt IsNewButtonEnabled="True"
NewButtonClick="TabControl_NewButtonClick"
Name="tabControl" />private void TabControl_NewButtonClick(object sender, EventArgs e)
{
TabItemExt newItem = new TabItemExt()
{
Header = $"Tab {tabControl.Items.Count + 1}",
Content = new TextBlock() { Text = "New tab content" }
};
tabControl.Items.Add(newItem);
}<syncfusion:TabControlExt TabScrollButtonVisibility="Visible"
TabScrollStyle="Extended"
Name="tabControl" />| Property | Type | Purpose |
|---|---|---|
| Collection | Collection of TabItemExt objects |
| TabItemExt | Currently selected tab item |
| Dock | Tab position (Top, Bottom, Left, Right) |
| CloseButtonType | Close button display mode |
| bool | Show/hide new tab button |
| bool | Enable tab list navigation menu |
| bool | Enable built-in context menu |
| Visibility | Show/hide navigation scroll buttons |
| Event | Purpose |
|---|---|
| Fires when selected tab changes |
| Fires when new tab button is clicked |
| Fires before tab item closes |
| Fires after tab item closes |