Skip to content

Add AP to control TabControl Headers behavior #3873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

corvinsz
Copy link
Member

fixes #3863

This PR adds a new attached property (materialDesign:TabAssist.HeaderBehavior) to let consumers decide on how to display the headers of a TabControl.

Currently the headers are always contained inside of a ScrollViewer, which is not always ideal. Under certain circumstances the user is unable to click on "the next" tab, because it is simply not shown:

455977593-05159782-e2c0-48dc-96f7-40ac3e8f9c08

With the new AP TabControls can be forced to wrap their headers in a WrapPanel, e.g.: materialDesign:TabAssist.HeaderBehavior="Wrapping".
There is basically now a trigger in the ControlTemplate which swaps out the header of the TabControl.

455977937-18020632-72d4-45b5-a850-e11e186f5825

Note

As of right now the AP can't be changed at runtime. Apparently applying the template when the property changes isn't enough. The TabControl sometimes doesn't show it's content when selecting a Tab after changing the materialDesign:TabAssist.HeaderBehavior. I would argue having the need of changing this AP at runtime is rather rare.

private static void OnHeaderBehaviorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
    if (d is TabControl tabControl)
    {
        tabControl.ApplyTemplate();
    }
}

@Keboo Keboo added this to the 5.3.0 milestone Jun 19, 2025
@Keboo
Copy link
Member

Keboo commented Jun 27, 2025

Soerry for the delay on this. I think a better implementation would be to create a secondary style and/or control template for the TabControl that implements it with the WrapPanel. The default WPF behavior contradicts the material design behavior, so we want the current (horizontal scroll behavior) to be the default, but in cases like this we have often put in secondary styles that people can set if they want a different behavior.

@Keboo Keboo self-requested a review June 27, 2025 06:26
@Keboo Keboo modified the milestones: 5.3.0, 5.3.1 Jun 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TabItem in two rows
2 participants