<ui:Page
    x:Class="ModernWpf.SampleApp.ControlPages.TabControlPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:ui="http://schemas.modernwpf.com/2019"
    xmlns:sc="clr-namespace:SamplesCommon;assembly=SamplesCommon"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    mc:Ignorable="d">

    <Page.Resources>
        <Style TargetType="TabControl" BasedOn="{StaticResource DefaultTabControlStyle}">
            <Setter Property="MinHeight" Value="475" />
        </Style>
    </Page.Resources>

    <ScrollViewer>
        <ui:SimpleStackPanel Style="{StaticResource ControlPageContentPanelStyle}">
            <sc:ControlExample HeaderText="A basic TabControl">
                <TabControl x:Name="tabControl">
                    <ui:TabControlHelper.TabStripHeader>
                        <Button
                            Content="Header"
                            HorizontalAlignment="Stretch"
                            VerticalAlignment="Stretch"
                            ui:FocusVisualHelper.FocusVisualMargin="0"
                            Visibility="{Binding IsChecked, ElementName=ShowHeaderAndFooterCheckBox, Converter={StaticResource BooleanToVisibilityConverter}}" />
                    </ui:TabControlHelper.TabStripHeader>
                    <ui:TabControlHelper.TabStripFooter>
                        <Button
                            Content="Footer"
                            HorizontalAlignment="Stretch"
                            VerticalAlignment="Stretch"
                            ui:FocusVisualHelper.FocusVisualMargin="0"
                            Visibility="{Binding IsChecked, ElementName=ShowHeaderAndFooterCheckBox, Converter={StaticResource BooleanToVisibilityConverter}}" />
                    </ui:TabControlHelper.TabStripFooter>
                </TabControl>

                <sc:ControlExample.Options>
                    <ui:SimpleStackPanel Style="{StaticResource OptionsPanelStyle}">
                        <ui:RadioButtons
                            Header="TabStripPlacement"
                            ItemsSource="{Binding Source={x:Type Dock}, Converter={StaticResource EnumValuesConverter}}"
                            SelectedItem="{Binding ElementName=tabControl, Path=TabStripPlacement}" />
                        <CheckBox
                            x:Name="ShowHeaderAndFooterCheckBox"
                            Content="Show header and footer" />
                    </ui:SimpleStackPanel>
                </sc:ControlExample.Options>
            </sc:ControlExample>

            <sc:ControlExample HeaderText="TabControl with color tab icons">
                <sc:ControlExample.Example>
                    <StackPanel>
                        <TextBlock
                            TextWrapping="Wrap"
                            Margin="0,0,0,12"
                            Text="Use BitmapIcon.ShowAsMonochrome=&quot;False&quot; to display full color icons in the TabItem" />

                        <TabControl
                            x:Name="TabView4"
                            SelectedIndex="0"
                            MinWidth="490"
                            MinHeight="0">
                            <TabControl.Items>
                                <TabItem Header="CMD Prompt">
                                    <ui:TabItemHelper.Icon>
                                        <ui:BitmapIcon UriSource="/Assets/TabViewIcons/cmd.png" ShowAsMonochrome="False" />
                                    </ui:TabItemHelper.Icon>
                                </TabItem>
                                <TabItem Header="Powershell">
                                    <ui:TabItemHelper.Icon>
                                        <ui:BitmapIcon UriSource="/Assets/TabViewIcons/powershell.png" ShowAsMonochrome="False" />
                                    </ui:TabItemHelper.Icon>
                                </TabItem>
                                <TabItem Header="Windows Subsystem for Linux">
                                    <ui:TabItemHelper.Icon>
                                        <ui:BitmapIcon UriSource="/Assets/TabViewIcons/linux.png" ShowAsMonochrome="False" />
                                    </ui:TabItemHelper.Icon>
                                </TabItem>
                            </TabControl.Items>
                        </TabControl>
                    </StackPanel>
                </sc:ControlExample.Example>
            </sc:ControlExample>

            <sc:ControlExample HeaderText="You can put custom content in TabStripHeader and TabStripFooter">
                <sc:ControlExample.Example>
                    <StackPanel>
                        <TextBlock
                            TextWrapping="Wrap"
                            Margin="0,0,0,24"
                            Text="You can put any content in the TabStripHeader and TabStripFooter areas" />

                        <TabControl
                            SelectedIndex="0"
                            Margin="-12"
                            Loaded="TabView_Loaded"
                            MinHeight="475">
                            <ui:TabControlHelper.TabStripHeader>
                                <TextBlock
                                    Text="TabStripHeader Content"
                                    VerticalAlignment="Center"
                                    Margin="8,6"
                                    Style="{DynamicResource BaseTextBlockStyle}" />
                            </ui:TabControlHelper.TabStripHeader>
                            <ui:TabControlHelper.TabStripFooter>
                                <TextBlock
                                    Text="TabStripFooter Content"
                                    VerticalAlignment="Center"
                                    HorizontalAlignment="Right"
                                    Margin="6"
                                    Style="{DynamicResource BaseTextBlockStyle}" />
                            </ui:TabControlHelper.TabStripFooter>
                        </TabControl>
                    </StackPanel>
                </sc:ControlExample.Example>
            </sc:ControlExample>

            <sc:ControlExample HeaderText="A TabControl with accent colored TabStrip background">
                <TabControl
                    x:Name="tabControl3"
                    ui:ThemeManager.HasThemeResources="True">
                    <TabControl.Resources>
                        <ui:ResourceDictionaryEx>
                            <ui:ResourceDictionaryEx.ThemeDictionaries>
                                <ResourceDictionary x:Key="Light">
                                    <SolidColorBrush x:Key="TabViewBackground" Color="{DynamicResource SystemAccentColorLight2}" />
                                </ResourceDictionary>
                                <ResourceDictionary x:Key="Dark">
                                    <SolidColorBrush x:Key="TabViewBackground" Color="{DynamicResource SystemAccentColorDark2}" />
                                </ResourceDictionary>
                            </ui:ResourceDictionaryEx.ThemeDictionaries>
                        </ui:ResourceDictionaryEx>
                    </TabControl.Resources>
                </TabControl>
            </sc:ControlExample>

            <sc:ControlExample HeaderText="A TabControl with customized headers">
                <TabControl x:Name="tabControl2">
                    <TabControl.Resources>
                        <sys:Double x:Key="TabViewItemHeaderFontSize">24</sys:Double>
                        <sys:Double x:Key="TabViewItemHeaderIconSize">32</sys:Double>
                    </TabControl.Resources>
                    <TabControl.ItemContainerStyle>
                        <Style TargetType="TabItem" BasedOn="{StaticResource DefaultTabItemStyle}">
                            <Setter Property="FontFamily" Value="Courier New" />
                        </Style>
                    </TabControl.ItemContainerStyle>
                </TabControl>
            </sc:ControlExample>
        </ui:SimpleStackPanel>
    </ScrollViewer>
</ui:Page>
