Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create HeaderTemplate for TabControl in programatically?

I have a tabcontrol in mainpage. I want to add close button to header template of tab items. How can i add header template to tabitems in c# code. please help..

like image 381
CobanBeyi Avatar asked Jan 29 '26 13:01

CobanBeyi


1 Answers

See It : type this codes in resources of UserControl

<Style TargetType='sdk:TabItem'>
        <Setter Property='HeaderTemplate'>
            <Setter.Value>
                <DataTemplate>
                    <StackPanel Orientation='Horizontal'
                                            Background='Transparent'>
                        <TextBlock Text='{Binding}' />
                        <!--<Button Command="{Binding RemoveItemCommand}" VerticalAlignment='Center'
                                        Style="{StaticResource CloseButton}"
                                        Margin="5,0,0,0"
                                        Content="M0,0 L6,6 M6, 0 L0,6"
                                        ToolTipService.ToolTip="Remove item" />-->
                        <Button x:Name='btnCloaseTab'
                                        Click='btnCloaseTab_Click'
                                        VerticalAlignment='Center'
                                        Style="{StaticResource CloseButton}"
                                        Margin="5,0,0,0"
                                        Content="M0,0 L6,6 M6, 0 L0,6"
                                        ToolTipService.ToolTip="بستن زبانه" />
                    </StackPanel>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>
like image 149
Mr Reza Avatar answered Feb 03 '26 07:02

Mr Reza