Class SfTabControl
Represents a tab control that supports features such as drag-and-drop, pinning, tear-off, and dynamic tab management. Extends the standard WPF TabControl with enhanced functionality including tab reordering, content management, and command support.
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:sync="clr-namespace:Syncfusion.Windows.Controls;assembly=Syncfusion.SfChromelessWindow.WPF">
<Grid>
<!-- Basic SfTabControl with drag-drop enabled -->
<sync:SfTabControl AllowDragDrop="True" EnableNewButton="True">
<sync:SfTabItem Header="Tab 1" CloseButtonVisibility="Visible">
<TextBlock Text="Content for Tab 1"/>
</sync:SfTabItem>
<sync:SfTabItem Header="Tab 2" PinButtonVisibility="Visible">
<TextBlock Text="Content for Tab 2"/>
</sync:SfTabItem>
</sync:SfTabControl>
</Grid>
</Window>
Inheritance
Implements
Namespace: Syncfusion.Windows.Controls
Assembly: Syncfusion.SfChromelessWindow.Wpf.dll
Syntax
public class SfTabControl : TabControl, IDisposable
Constructors
SfTabControl()
Initializes a new instance of the SfTabControl class.
Declaration
public SfTabControl()
Fields
AllowDragDropProperty
Identifies the AllowDragDrop dependency property.
Declaration
public static readonly DependencyProperty AllowDragDropProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
EnableNewTabButtonProperty
Identifies the EnableNewButton dependency property.
Declaration
public static readonly DependencyProperty EnableNewTabButtonProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
NewTabButtonStyleProperty
Identifies the NewButtonStyle dependency property.
Declaration
public static readonly DependencyProperty NewTabButtonStyleProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
NewTabButtonTemplateProperty
Identifies the NewTabButtonTemplate dependency property.
Declaration
public static readonly DependencyProperty NewTabButtonTemplateProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
Properties
AllowDragDrop
Gets or sets a value indicating whether drag-and-drop operations are allowed on tabs.
Declaration
public bool AllowDragDrop { get; set; }
Property Value
| Type |
|---|
| System.Boolean |
EnableNewTabButton
Gets or sets a value indicating whether the new tab button is enabled and visible.
Declaration
public bool EnableNewTabButton { get; set; }
Property Value
| Type |
|---|
| System.Boolean |
NewTabButtonStyle
Gets or sets the style for the new tab button.
Declaration
public Style NewTabButtonStyle { get; set; }
Property Value
| Type |
|---|
| System.Windows.Style |
NewTabButtonTemplate
Gets or sets the data template for the new tab button content.
Declaration
public DataTemplate NewTabButtonTemplate { get; set; }
Property Value
| Type |
|---|
| System.Windows.DataTemplate |
Methods
Dispose()
Releases all resources used by the SfTabControl. Removes command bindings and cleans up event handlers to avoid memory leaks.
Declaration
public void Dispose()
OnApplyTemplate()
Called when the template is applied to the control.
Declaration
public override void OnApplyTemplate()
OnItemsChanged(NotifyCollectionChangedEventArgs)
Raises the ItemsChanged event.
Declaration
protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Specialized.NotifyCollectionChangedEventArgs | e | The event data. |
OnKeyDown(KeyEventArgs)
Prevent base TabControl from running default keyboard path after we handled it.
Declaration
protected override void OnKeyDown(KeyEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Input.KeyEventArgs | e |
OnPreviewKeyDown(KeyEventArgs)
Handles preview key down to support Ctrl+T (new tab) and Ctrl+Tab navigation.
Declaration
protected override void OnPreviewKeyDown(KeyEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Input.KeyEventArgs | e |
OnPreviewMouseDown(MouseButtonEventArgs)
Handles preview mouse down to support middle-click close on tab headers.
Declaration
protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Input.MouseButtonEventArgs | e |
OnSelectionChanged(SelectionChangedEventArgs)
Raises the SelectionChanged event.
Declaration
protected override void OnSelectionChanged(SelectionChangedEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Controls.SelectionChangedEventArgs | e | The event data. |
Events
NewTabRequested
Event raised when a new tab is being added to the control.
Declaration
public event EventHandler<NewTabRequestedEventArgs> NewTabRequested
Event Type
| Type |
|---|
| System.EventHandler<NewTabRequestedEventArgs> |
PreviewTabMerge
Event raised to allow consumers to validate or cancel an incoming tab merge operation.
Declaration
public event EventHandler<TabMergePreviewEventArgs> PreviewTabMerge
Event Type
| Type |
|---|
| System.EventHandler<TabMergePreviewEventArgs> |