Loading...
Loading...
Compare original and translation side by side
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><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;
}
}using Syncfusion.Windows.Tools.Controls;
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
// 创建TabControl实例
TabControlExt tabControlExt = new TabControlExt();
tabControlExt.Height = 100;
tabControlExt.Width = 280;
// 创建并添加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}");
}// 处理标签选择变化
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><!-- 在TabControl和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 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 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" /><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 |
| 属性 | 类型 | 用途 |
|---|---|---|
| Collection | TabItemExt对象集合 |
| TabItemExt | 当前选中的标签项 |
| Dock | 标签位置(Top、Bottom、Left、Right) |
| CloseButtonType | 关闭按钮显示模式 |
| bool | 显示/隐藏新建标签按钮 |
| bool | 启用标签列表导航菜单 |
| bool | 启用内置上下文菜单 |
| Visibility | 显示/隐藏导航滚动按钮 |
| Event | Purpose |
|---|---|
| Fires when selected tab changes |
| Fires when new tab button is clicked |
| Fires before tab item closes |
| Fires after tab item closes |
| 事件 | 用途 |
|---|---|
| 选中标签变化时触发 |
| 点击新建标签按钮时触发 |
| 标签项关闭前触发 |
| 标签项关闭后触发 |