syncfusion-wpf-tabbedwindow
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseImplementing Syncfusion WPF Tabbed Windows
实现Syncfusion WPF Tabbed Window
A comprehensive guide for implementing the Syncfusion WPF Tabbed Window control, which combines with to create professional document-based applications with advanced tab management, tear-off windows, and cross-window tab merging capabilities.
SfChromelessWindowSfTabControl本文是关于实现Syncfusion WPF Tabbed Window控件的综合指南,该控件结合与,可创建具备高级标签管理、可拖离窗口和跨窗口标签合并功能的专业文档类应用程序。
SfChromelessWindowSfTabControlWhen to Use This Skill
适用场景
Use this skill when you need to:
- Build document-based applications with multiple documents in tabs (similar to Visual Studio, Visual Studio Code, or modern web browsers)
- Implement browser-style tab interfaces with integrated chrome and tab navigation
- Create multi-document interfaces (MDI) with modern tabbed layouts instead of traditional MDI windows
- Enable tear-off functionality allowing users to drag tabs out to create floating windows
- Support tab merging between multiple windows through drag-and-drop operations
- Implement dynamic tab management with add/close/select operations and new tab buttons
- Build MVVM-compatible tabbed interfaces with data binding to observable collections
- Create professional desktop applications requiring flexible workspace organization
- Implement code editors, document viewers, or content management tools with tabbed navigation
- Support multiple window layouts with tabs integrated into window chrome or as content
This skill covers all aspects of the Tabbed Window control including setup, window modes, tab management, data binding, tear-off windows, tab merging, and customization.
当你需要完成以下需求时,可使用本技能:
- 构建基于文档的应用程序,在标签页中管理多个文档(类似Visual Studio、Visual Studio Code或现代网页浏览器)
- 实现浏览器式标签界面,集成窗口边框与标签导航功能
- 创建多文档界面(MDI),采用现代标签布局替代传统MDI窗口
- 启用拖离功能,允许用户将标签拖出以创建浮动窗口
- 支持跨窗口标签合并,通过拖拽操作在多个窗口间移动标签
- 实现动态标签管理,支持添加/关闭/选择标签及新建标签按钮
- 构建兼容MVVM的标签界面,将标签与可观察集合进行数据绑定
- 创建专业桌面应用程序,需要灵活的工作区组织方式
- 实现代码编辑器、文档查看器或内容管理工具,采用标签式导航
- 支持多窗口布局,标签可集成到窗口边框中或作为内容展示
本指南涵盖Tabbed Window控件的所有方面,包括设置、窗口模式、标签管理、数据绑定、可拖离窗口、标签合并和自定义配置。
Component Overview
组件概述
The Tabbed Window is a powerful combination of and that enables professional document-based applications with:
SfChromelessWindowSfTabControl- Drag-and-Drop Reordering - Intuitive tab reordering within the tab bar or between windows
- Tear-Off Windows - Create floating windows by dragging tabs outside window boundaries
- Tab Merging - Move tabs between multiple TabbedWindow instances with validation
- Flexible Tab Management - Dynamic add, remove, and select operations with close/new tab buttons
- MVVM Support - Full data binding through ItemsSource for data-driven scenarios
- Window Type Modes - Tabbed mode (chrome-integrated) or Normal mode (content-based)
- Content Customization - Templates for headers, icons, and content
- Event-Driven Architecture - Comprehensive events for all tab operations
Key Assemblies Required:
Syncfusion.SfChromelessWindow.WPFSyncfusion.Shared.WPF
Namespace:
xml
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"Tabbed Window是与的强大组合,可为专业文档类应用程序提供以下功能:
SfChromelessWindowSfTabControl- 拖拽重排 - 在标签栏内或跨窗口直观地重新排列标签
- 可拖离窗口 - 将标签拖出窗口边界即可创建浮动窗口
- 标签合并 - 在多个TabbedWindow实例间移动标签,并支持验证操作
- 灵活的标签管理 - 动态添加、删除、选择标签,支持关闭/新建标签按钮
- MVVM支持 - 通过ItemsSource实现完整的数据绑定,适用于数据驱动场景
- 窗口类型模式 - 标签模式(集成窗口边框)或普通模式(基于内容)
- 内容自定义 - 可为标签头、图标和内容设置模板
- 事件驱动架构 - 为所有标签操作提供全面的事件支持
所需关键程序集:
Syncfusion.SfChromelessWindow.WPFSyncfusion.Shared.WPF
命名空间:
xml
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"Documentation and Navigation Guide
文档与导航指南
Getting Started
快速入门
📄 Read: references/getting-started.md
When you need to:
- Install and reference required assemblies
- Create your first tabbed window in XAML or code-behind
- Understand Window Type Modes (Tabbed vs Normal)
- Choose the right mode for your application
- Create basic tab items
- Configure essential properties
Key Topics: Installation, basic window setup, property, Tabbed vs Normal mode comparison, assembly references, namespace imports
WindowType📄 阅读: references/getting-started.md
当你需要完成以下操作时:
- 安装并引用所需程序集
- 在XAML或代码后置中创建首个标签窗口
- 了解窗口类型模式(标签模式vs普通模式)
- 为应用选择合适的模式
- 创建基础标签项
- 配置核心属性
核心主题: 安装、基础窗口设置、属性、标签模式与普通模式对比、程序集引用、命名空间导入
WindowTypeTab Management
标签管理
📄 Read: references/tab-management.md
When you need to:
- Add close buttons to tabs
- Enable the new tab (+) button
- Handle NewTabRequested event for dynamic tab creation
- Customize the new tab button appearance
- Implement keyboard shortcuts (Ctrl+Tab, Ctrl+Shift+Tab, Ctrl+T)
- Support middle-click to close tabs
- Programmatically add, remove, or select tabs
Key Topics: , , event, , keyboard shortcuts, tab selection
CloseButtonVisibilityEnableNewTabButtonNewTabRequestedNewTabButtonStyle📄 阅读: references/tab-management.md
当你需要完成以下操作时:
- 为标签添加关闭按钮
- 启用新建标签(+)按钮
- 处理NewTabRequested事件以动态创建标签
- 自定义新建标签按钮的外观
- 实现键盘快捷键(Ctrl+Tab、Ctrl+Shift+Tab、Ctrl+T)
- 支持中键点击关闭标签
- 以编程方式添加、删除或选择标签
核心主题: 、、事件、、键盘快捷键、标签选择
CloseButtonVisibilityEnableNewTabButtonNewTabRequestedNewTabButtonStyleData Binding (MVVM)
数据绑定(MVVM)
📄 Read: references/data-binding.md
When you need to:
- Bind tabs to a ViewModel collection
- Implement MVVM pattern with tabbed windows
- Use for data-driven tab scenarios
ItemsSource - Create tab models and ViewModels
- Customize tab headers and content through templates
- Configure and
ItemTemplateContentTemplate - Use for tab styling
ItemContainerStyle - Handle dynamic collection updates with ObservableCollection
Key Topics: MVVM pattern, binding, , , , ObservableCollection, tab models
ItemsSourceItemTemplateContentTemplateItemContainerStyle📄 阅读: references/data-binding.md
当你需要完成以下操作时:
- 将标签绑定到ViewModel集合
- 结合标签窗口实现MVVM模式
- 使用实现数据驱动的标签场景
ItemsSource - 创建标签模型与ViewModel
- 通过模板自定义标签头和内容
- 配置与
ItemTemplateContentTemplate - 使用设置标签样式
ItemContainerStyle - 通过ObservableCollection处理动态集合更新
核心主题: MVVM模式、绑定、、、、ObservableCollection、标签模型
ItemsSourceItemTemplateContentTemplateItemContainerStyleTab Merging and Floating Windows
标签合并与浮动窗口
📄 Read: references/merge-tabs.md
When you need to:
- Enable tear-off functionality to create floating windows
- Understand how tabs become independent windows
- Reattach floating tabs back to main window
- Merge tabs between multiple windows
- Validate merge operations with event
PreviewTabMerge - Control which tabs can be moved
- Transform items during merge operations
- Handle multi-window workspace scenarios
Key Topics: Tear-off windows, drag-outside behavior, floating window lifecycle, event, , cross-window merging, merge validation
PreviewTabMergeTabMergePreviewEventArgs📄 阅读: references/merge-tabs.md
当你需要完成以下操作时:
- 启用拖离功能以创建浮动窗口
- 了解标签如何转换为独立窗口
- 将浮动标签重新附加到主窗口
- 在多个窗口间合并标签
- 通过事件验证合并操作
PreviewTabMerge - 控制可移动的标签范围
- 在合并操作中转换项
- 处理多窗口工作区场景
核心主题: 可拖离窗口、拖出边界行为、浮动窗口生命周期、事件、、跨窗口合并、合并验证
PreviewTabMergeTabMergePreviewEventArgsCustomization and Styling
自定义与样式设置
📄 Read: references/customization.md
When you need to:
- Apply Syncfusion themes
- Customize window chrome appearance
- Style tab headers and content areas
- Create custom header and content templates
- Customize close button appearance
- Configure drag-drop visual feedback
- Set colors, fonts, and spacing
- Implement responsive design
- Follow best practices for professional appearance
Key Topics: Theme application, style customization, template customization, visual appearance, , responsive design, professional styling
AllowDragDrop📄 阅读: references/customization.md
当你需要完成以下操作时:
- 应用Syncfusion主题
- 自定义窗口边框外观
- 设置标签头和内容区域的样式
- 创建自定义的标签头和内容模板
- 自定义关闭按钮的外观
- 配置拖拽操作的视觉反馈
- 设置颜色、字体和间距
- 实现响应式设计
- 遵循专业外观的最佳实践
核心主题: 主题应用、样式自定义、模板自定义、视觉外观、、响应式设计、专业样式设置
AllowDragDropQuick Start Example
快速入门示例
Basic Tabbed Window with Close Buttons
带关闭按钮的基础标签窗口
XAML:
xml
<Window x:Class="TabbedWindowApp.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">
<syncfusion:SfChromelessWindow
Title="Document Manager"
WindowType="Tabbed"
Height="600"
Width="900">
<syncfusion:SfTabControl
AllowDragDrop="True"
EnableNewTabButton="True"
NewTabRequested="OnNewTabRequested">
<syncfusion:SfTabItem
Header="Document 1"
CloseButtonVisibility="Visible">
<TextBlock Text="Welcome to Document 1"
Margin="20"/>
</syncfusion:SfTabItem>
<syncfusion:SfTabItem
Header="Document 2"
CloseButtonVisibility="Visible">
<TextBlock Text="Welcome to Document 2"
Margin="20"/>
</syncfusion:SfTabItem>
</syncfusion:SfTabControl>
</syncfusion:SfChromelessWindow>
</Window>Code-Behind:
csharp
using Syncfusion.Windows.Controls;
public partial class MainWindow : SfChromelessWindow
{
public MainWindow()
{
InitializeComponent();
}
private void OnNewTabRequested(object sender, NewTabRequestedEventArgs e)
{
var tabCount = ((SfTabControl)sender).Items.Count;
var newTab = new SfTabItem
{
Header = $"Document {tabCount + 1}",
Content = new TextBlock
{
Text = $"New Document {tabCount + 1}",
Margin = new Thickness(20)
},
CloseButtonVisibility = Visibility.Visible
};
e.Item = newTab;
}
}XAML:
xml
<Window x:Class="TabbedWindowApp.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">
<syncfusion:SfChromelessWindow
Title="Document Manager"
WindowType="Tabbed"
Height="600"
Width="900">
<syncfusion:SfTabControl
AllowDragDrop="True"
EnableNewTabButton="True"
NewTabRequested="OnNewTabRequested">
<syncfusion:SfTabItem
Header="Document 1"
CloseButtonVisibility="Visible">
<TextBlock Text="Welcome to Document 1"
Margin="20"/>
</syncfusion:SfTabItem>
<syncfusion:SfTabItem
Header="Document 2"
CloseButtonVisibility="Visible">
<TextBlock Text="Welcome to Document 2"
Margin="20"/>
</syncfusion:SfTabItem>
</syncfusion:SfTabControl>
</syncfusion:SfChromelessWindow>
</Window>代码后置:
csharp
using Syncfusion.Windows.Controls;
public partial class MainWindow : SfChromelessWindow
{
public MainWindow()
{
InitializeComponent();
}
private void OnNewTabRequested(object sender, NewTabRequestedEventArgs e)
{
var tabCount = ((SfTabControl)sender).Items.Count;
var newTab = new SfTabItem
{
Header = $"Document {tabCount + 1}",
Content = new TextBlock
{
Text = $"New Document {tabCount + 1}",
Margin = new Thickness(20)
},
CloseButtonVisibility = Visibility.Visible
};
e.Item = newTab;
}
}Common Patterns
常见模式
Pattern 1: Document Editor with Drag-Drop and New Tab
模式1:带拖拽与新建标签的文档编辑器
xml
<syncfusion:SfChromelessWindow WindowType="Tabbed">
<syncfusion:SfTabControl
AllowDragDrop="True"
EnableNewTabButton="True"
NewTabRequested="OnNewTabRequested">
<!-- Tabs here -->
</syncfusion:SfTabControl>
</syncfusion:SfChromelessWindow>xml
<syncfusion:SfChromelessWindow WindowType="Tabbed">
<syncfusion:SfTabControl
AllowDragDrop="True"
EnableNewTabButton="True"
NewTabRequested="OnNewTabRequested">
<!-- Tabs here -->
</syncfusion:SfTabControl>
</syncfusion:SfChromelessWindow>Pattern 2: MVVM Data-Bound Tabs
模式2:MVVM数据绑定标签
xml
<syncfusion:SfTabControl ItemsSource="{Binding OpenDocuments}">
<syncfusion:SfTabControl.ItemContainerStyle>
<Style TargetType="syncfusion:SfTabItem">
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{Binding Title}" />
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</syncfusion:SfTabControl.ItemContainerStyle>
<syncfusion:SfTabControl.ContentTemplate>
<DataTemplate>
<TextBlock Text="{Binding Content}" />
</DataTemplate>
</syncfusion:SfTabControl.ContentTemplate>
</syncfusion:SfTabControl>xml
<syncfusion:SfTabControl ItemsSource="{Binding OpenDocuments}">
<syncfusion:SfTabControl.ItemContainerStyle>
<Style TargetType="syncfusion:SfTabItem">
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{Binding Title}" />
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</syncfusion:SfTabControl.ItemContainerStyle>
<syncfusion:SfTabControl.ContentTemplate>
<DataTemplate>
<TextBlock Text="{Binding Content}" />
</DataTemplate>
</syncfusion:SfTabControl.ContentTemplate>
</syncfusion:SfTabControl>Pattern 3: Multi-Window with Merge Validation
模式3:带合并验证的多窗口
csharp
private void OnPreviewTabMerge(object sender, TabMergePreviewEventArgs e)
{
var draggedItem = e.DraggedItem;
// Validate merge operation
if (draggedItem is DocumentTab doc && doc.IsReadOnly)
{
e.Allow = false;
MessageBox.Show("Cannot move read-only documents");
return;
}
e.Allow = true;
}csharp
private void OnPreviewTabMerge(object sender, TabMergePreviewEventArgs e)
{
var draggedItem = e.DraggedItem;
// Validate merge operation
if (draggedItem is DocumentTab doc && doc.IsReadOnly)
{
e.Allow = false;
MessageBox.Show("Cannot move read-only documents");
return;
}
e.Allow = true;
}Key Properties and Events
核心属性与事件
Core Properties
核心属性
| Property | Type | Description |
|---|---|---|
| WindowType | |
| bool | Enable drag-drop reordering and tear-off |
| bool | Show/hide the new tab (+) button |
| object | Currently active tab |
| int | Index of active tab |
| IEnumerable | Bind tabs to a collection (MVVM) |
| Visibility | Show/hide close button per tab |
| 属性 | 类型 | 描述 |
|---|---|---|
| WindowType | |
| bool | 启用拖拽重排与拖离功能 |
| bool | 显示/隐藏新建标签(+)按钮 |
| object | 当前激活的标签 |
| int | 激活标签的索引 |
| IEnumerable | 将标签绑定到集合(MVVM场景) |
| Visibility | 控制单个标签的关闭按钮显示/隐藏 |
Important Events
重要事件
| Event | Description |
|---|---|
| Fired when user clicks the + button; set |
| Fired before tab moves between windows; set |
| Fired when active tab changes |
| 事件 | 描述 |
|---|---|
| 用户点击+按钮时触发;设置 |
| 标签跨窗口移动前触发;设置 |
| 激活标签变更时触发 |
Styling Properties
样式属性
| Property | Description |
|---|---|
| Style for the new tab button |
| DataTemplate for tab headers |
| DataTemplate for tab content |
| Style for SfTabItem containers |
| 属性 | 描述 |
|---|---|
| 新建标签按钮的样式 |
| 标签头的数据模板 |
| 标签内容的数据模板 |
| SfTabItem容器的样式 |
Common Use Cases
常见用例
Use Case 1: Code Editor or IDE
用例1:代码编辑器或IDE
Scenario: Building a development tool with multiple file tabs
Mode: Tabbed (chrome-integrated)
Features: Drag-drop reordering, close buttons, new tab button, tear-off for multi-monitor
Mode: Tabbed (chrome-integrated)
Features: Drag-drop reordering, close buttons, new tab button, tear-off for multi-monitor
场景: 构建带多文件标签的开发工具
模式: Tabbed(集成窗口边框)
功能: 拖拽重排、关闭按钮、新建标签按钮、多显示器拖离支持
模式: Tabbed(集成窗口边框)
功能: 拖拽重排、关闭按钮、新建标签按钮、多显示器拖离支持
Use Case 2: Document Management System
用例2:文档管理系统
Scenario: Enterprise application managing multiple documents
Mode: Tabbed or Normal
Features: MVVM binding, tab merging, dynamic add/remove, data-driven tabs
Mode: Tabbed or Normal
Features: MVVM binding, tab merging, dynamic add/remove, data-driven tabs
场景: 管理多文档的企业级应用程序
模式: Tabbed或Normal
功能: MVVM绑定、标签合并、动态添加/删除、数据驱动标签
模式: Tabbed或Normal
功能: MVVM绑定、标签合并、动态添加/删除、数据驱动标签
Use Case 3: Multi-Window Workspace
用例3:多窗口工作区
Scenario: Professional tool with floating panels and documents
Mode: Tabbed
Features: Tear-off windows, cross-window merging, merge validation, flexible layouts
Mode: Tabbed
Features: Tear-off windows, cross-window merging, merge validation, flexible layouts
场景: 带浮动面板与文档的专业工具
模式: Tabbed
功能: 可拖离窗口、跨窗口合并、合并验证、灵活布局
模式: Tabbed
功能: 可拖离窗口、跨窗口合并、合并验证、灵活布局
Use Case 4: Browser-Style Application
用例4:浏览器式应用程序
Scenario: Web-like interface with browser tabs
Mode: Tabbed
Features: Close buttons, new tab button, drag reordering, keyboard shortcuts
Mode: Tabbed
Features: Close buttons, new tab button, drag reordering, keyboard shortcuts
场景: 类网页界面的浏览器式标签
模式: Tabbed
功能: 关闭按钮、新建标签按钮、拖拽重排、键盘快捷键
模式: Tabbed
功能: 关闭按钮、新建标签按钮、拖拽重排、键盘快捷键
Best Practices
最佳实践
- Choose the Right Mode: Use Tabbed mode for document-centric apps, Normal mode when tabs are secondary navigation
- Enable Drag-Drop: Set for intuitive reordering and tear-off functionality
AllowDragDrop="True" - Handle NewTabRequested: Always implement this event handler when
EnableNewTabButton="True" - MVVM Pattern: Use binding for data-driven scenarios with clean separation of concerns
ItemsSource - Validate Merges: Use to control which tabs can be moved between windows
PreviewTabMerge - Keyboard Support: Document keyboard shortcuts for users (Ctrl+Tab, Ctrl+Shift+Tab, Ctrl+T)
- Visual Feedback: Ensure drag-drop operations have clear visual indicators for user guidance
- 选择合适模式: 文档中心类应用使用Tabbed模式,标签为次要导航时使用Normal模式
- 启用拖拽功能: 设置以支持直观的重排与拖离功能
AllowDragDrop="True" - 处理NewTabRequested事件: 当设置时,务必实现该事件处理程序
EnableNewTabButton="True" - 采用MVVM模式: 数据驱动场景使用绑定,实现关注点分离
ItemsSource - 验证合并操作: 使用控制可跨窗口移动的标签范围
PreviewTabMerge - 支持键盘快捷键: 为用户提供键盘快捷键文档(Ctrl+Tab、Ctrl+Shift+Tab、Ctrl+T)
- 提供视觉反馈: 确保拖拽操作有清晰的视觉提示,引导用户操作
Troubleshooting Quick Tips
故障排查快速提示
- Tabs not draggable? Verify is set
AllowDragDrop="True" - New tab button not appearing? Check and ensure event handler is attached
EnableNewTabButton="True" - Tab merging not working? Ensure both windows have enabled
AllowDragDrop - MVVM binding not working? Verify and
ItemTemplateare configuredContentTemplate - Assembly reference errors? Ensure both and
Syncfusion.SfChromelessWindow.WPFare referencedSyncfusion.Shared.WPF
- 标签无法拖拽? 确认已设置
AllowDragDrop="True" - 新建标签按钮不显示? 检查并确保已绑定事件处理程序
EnableNewTabButton="True" - 标签合并不生效? 确保所有窗口都已启用
AllowDragDrop - MVVM绑定不生效? 验证与
ItemTemplate配置正确ContentTemplate - 程序集引用错误? 确保已同时引用与
Syncfusion.SfChromelessWindow.WPFSyncfusion.Shared.WPF