Member Avatar for cool_intentions

Hi guys,
I need to put stop sign as small icon in the tab.

This is my XAML code:

<Window x:Class="assignment.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Canvas Height="282" Width="430">
        <TabControl  Height="271" Background="White" Width="405" Canvas.Left="0" Canvas.Top="0">
            <TabItem>
                
                <TabItem.Header>
                <DockPanel>
                    <TextBlock Text="Stop" Margin="2,0,0,0" VerticalAlignment="Center"></TextBlock>
                        
                    </DockPanel>
                </TabItem.Header>
                <Canvas >
                <Path Data="M80,81 L79.5,160.5 159.5,160.5 160.5,79.5 z" Fill="#FF737374"  Height="120" Stretch="Fill"  VerticalAlignment="Top" Width="120" Canvas.Left="136" Canvas.Top="54" />
                </Canvas>
            </TabItem>

            <TabItem>
                <TabItem.Header>
                    <DockPanel>
                        <TextBlock Text="Play" Margin="2,0,0,0" VerticalAlignment="Center"></TextBlock>
                        
                    </DockPanel>
                </TabItem.Header>
                <Canvas >
                    <Path Data="M240,80 L239.5,160.5 319.5,119.5 z" Fill="#FF737374" Width="120" Height="120"  Stretch="Fill" Canvas.Left="136" Canvas.Top="54"/>
                </Canvas>
            </TabItem>
        </TabControl>
    </Canvas>
</Window>

So, how can I accomplish that?

Recommended Answers

All 2 Replies

Are you referring to the tab's header? If so, you can just use a StackPanel in the TabItem.Header:

<TabItem.Header>
    <StackPanel Orientation="Horizontal">
        <Path Data="M0,0 L1,0 1,1 0,1 z"
              Fill="#FF737374"
              Width="23"
              Height="23"
              Stretch="Fill"/>
    </StackPanel>
</TabItem.Header>

Unless you intend to utilize the DockPanel in the TabItem's Header, I would not recommend adding it. It just adds unnecessary overhead to your program.

Member Avatar for cool_intentions

Thanks a lot nmaillet. That was just what I need.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.