Search code examples
c#wpftabcontroltabitem

Click on current tabItem of TabControl (in WPF)


I have ScrollViewer on my TabItem, what I want to do is when user touch header scrolling up, and I call this code

  ScrollMyProduct.ScrollToVerticalOffset(0);

But TabItem hasn't support clicking on only header of it, and SelectionChanged isn't work, because I clicking on current TabItem


Solution

  • A while back i did this changing the style of the header

    <Setter Property="HeaderTemplate">
        <Setter.Value>
            <DataTemplate>
                <Label Content={Binding}>
                    <Label.Style>
                        <Style TargetType="Label">
                            <EventSetter Event="MouseDoubleClick" Handler="TabItemMouseDoubleClick"/>
                        </Style>
                    </Label.Style>
                </Label>
            </DataTemplate>
        </Setter.Value>
    </Setter>
    

    Which bindings to the internal label of the tabheaders label item