Skip to content

Grouping in ComboBox #1198

@Apskalle

Description

@Apskalle

Describe the bug

Setting a group style in ComboBox dont seem to work in wpfui. Works in traditional wpf.
Itemspresenter does not show any items.

Tried other ItemsControl variants, like ListView and they work.
Also seems to be a problem with setting a custom ItemsPanel, maybe related.

To Reproduce

In this example MySourceView is a CollectionViewSource with a GroupDescription added

<ComboBox
     ItemsSource="{Binding MySourceView}" 
     SelectedValue="{Binding Path=MySelectedValue}">

     <ComboBox.ItemTemplate>
         <DataTemplate>
             <TextBlock Text="{Binding Description}"/>
         </DataTemplate>
     </ComboBox.ItemTemplate>

     <ComboBox.GroupStyle>
         <GroupStyle>
             <GroupStyle.ContainerStyle>
                 <Style TargetType="{x:Type GroupItem}">
                     <Setter Property="Template">
                         <Setter.Value>
                             <ControlTemplate TargetType="{x:Type GroupItem}">
                                 <Expander>
                                     <Expander.Header>
                                         <TextBlock Text="{Binding Path=Name}"/>
                                     </Expander.Header>
                                     <Expander.Content>
                                         **<ItemsPresenter/>**
                                     </Expander.Content>
                                 </Expander>
                             </ControlTemplate>
                         </Setter.Value>
                     </Setter>
                 </Style>
             </GroupStyle.ContainerStyle>
         </GroupStyle>
     </ComboBox.GroupStyle>
 </ComboBox>

Expected behavior

Items should appear in their respective Expander

Screenshots

OS version

Win 11

.NET version

Net 8

WPF-UI NuGet version

3.0.4

Additional context

Had a look at the control template and it has a Stackpanel with IsItemsHost="True", not an ItemsPresenter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions