Skip to content
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

Fix TreeView Expander Visibility #2561

Merged
merged 2 commits into from
Jan 17, 2022
Merged

Fix TreeView Expander Visibility #2561

merged 2 commits into from
Jan 17, 2022

Conversation

StefanoRivolta-Previero
Copy link
Contributor

When a TreeViewItem doesn't have any children items inside, the expander should be collapsed, otherwhise it creates a ghost minimum height that can't be removed.

Example:

given this treeview:
6fl9KYTl4c

<TreeView
    Grid.Row="0"
    ItemsSource="{Binding MovieCategories}"
    MinWidth="220" 
    SelectedItemChanged="TreeView_SelectedItemChanged">
    <TreeView.Resources>
        <Style TargetType="TreeViewItem" BasedOn="{StaticResource MaterialDesignTreeViewItem}">
            <Setter Property="materialDesign:TreeViewAssist.ExpanderSize" Value="32"/>
            <Setter Property="materialDesign:TreeViewAssist.ShowSelection" Value="False"/>
            <Setter Property="Background" Value="Green"/>
            <Setter Property="Padding" Value="0"/>
        </Style>
        <HierarchicalDataTemplate
            DataType="{x:Type domain:MovieCategory}"
            ItemsSource="{Binding Movies}">
            <TextBlock 
                Text="{Binding Name}"
                Margin="10"/>
        </HierarchicalDataTemplate>

        <DataTemplate DataType="{x:Type domain:Movie}">
            <TextBlock 
                Text="{Binding Name}"
                Background="red"
                Margin="8"
                ToolTip="{Binding Director}"/>
        </DataTemplate>
    </TreeView.Resources>
</TreeView>

When setting the textblock visibility to collapsed

Before

GYS0Xkp02G

After

4ZmHWN6Gkg

@Keboo Keboo added this to the 4.4.0 milestone Jan 17, 2022
@Keboo Keboo merged commit 1181fa9 into MaterialDesignInXAML:master Jan 17, 2022
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.

2 participants