8000 ComboBox Grouping Template · Issue #10629 · dotnet/wpf · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
ComboBox Grouping Template #10629
Closed
Closed
@shillingp

Description

@shillingp

<StackPanel
IsItemsHost="True"
KeyboardNavigation.DirectionalNavigation="Contained"
TextElement.FontSize="{TemplateBinding FontSize}" />

There is currently an issue with ComboBox grouping which causes only the group Header to be visible.

Minimum Reproduction

<CollectionViewSource x:Key="GroupedBooksViewSource">
	<CollectionViewSource.GroupDescriptions>
        <PropertyGroupDescription PropertyName="Publisher" />
    </CollectionViewSource.GroupDescriptions>
</CollectionViewSource>

<ComboBox
	ItemsSource="{Binding Source={StaticResource GroupedBooksViewSource}}"
	DisplayMemberPath="Name">
	<ComboBox.GroupStyle>
        <GroupStyle>
            <GroupStyle.HeaderTemplate>
                <DataTemplate DataType="{x:Type GroupItem}">
                    <TextBlock
                        Margin="10,5"
                        Style="{StaticResource BodyStrongTextBlockStyle}"
                        Text="{Binding Name}" />
                </DataTemplate>
            </GroupStyle.HeaderTemplate>
        </GroupStyle>
    </ComboBox.GroupStyle>
</ComboBox>

Recommended Solution

The solution to this is to change these lines to be the following:

<ItemsPresenter
     KeyboardNavigation.DirectionalNavigation="Contained" 
     TextElement.FontSize="{TemplateBinding FontSize}" /> 

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0