PleasantTabView / PleasantTabItem

April 2, 2026 · View on GitHub

A Chromium-style tab strip with scrollable tabs, an add button, and closable/editable tab items.

Basic usage

<PleasantTabView>
    <PleasantTabItem Header="Tab 1">
        <TextBlock Text="Content of tab 1" Margin="20" />
    </PleasantTabItem>
    <PleasantTabItem Header="Tab 2">
        <TextBlock Text="Content of tab 2" Margin="20" />
    </PleasantTabItem>
</PleasantTabView>

PleasantTabView properties

PropertyTypeDefaultDescription
AdderButtonIsVisiblebooltrueShows the + button to add new tabs
MaxWidthOfItemsPresenterdoubleCaps the tab strip width
MarginTypeNone / Little / ExtendedNoneMargin applied around the content area

PleasantTabView events

EventDescription
ClickOnAddingButtonFired when the + button is clicked — add a new tab here

PleasantTabItem properties

PropertyTypeDefaultDescription
IsClosablebooltrueShows the × close button on the tab
IsEditedIndicatorboolfalseShows a dot indicator (e.g. unsaved changes)

PleasantTabItem events

EventDescription
ClosingFired when the tab is about to close
CloseButtonClickFired when the × button is clicked

Dynamic tab management

// Add a tab when + is clicked
tabView.ClickOnAddingButton += (_, _) =>
{
    tabView.Items.Add(new PleasantTabItem
    {
        Header  = $"Tab {tabView.Items.Count + 1}",
        Content = new MyTabContent()
    });
};

// Prevent closing a specific tab
tab.Closing += (_, e) =>
{
    if (HasUnsavedChanges())
        e.Handled = true; // cancel close
};

Programmatic close

tab.CloseCore(); // removes the tab from its parent PleasantTabView

Data-bound tabs

<PleasantTabView ItemsSource="{Binding Tabs}">
    <PleasantTabView.ItemTemplate>
        <DataTemplate DataType="vm:TabViewModel">
            <PleasantTabItem Header="{Binding Title}"
                             IsEditedIndicator="{Binding IsModified}">
                <views:TabContentView DataContext="{Binding}" />
            </PleasantTabItem>
        </DataTemplate>
    </PleasantTabView.ItemTemplate>
</PleasantTabView>