Charlie Hopperson
Charlie Hopperson

Reputation: 415

WPF ListBox - using ItemTemplate in GroupStyle

I'm trying to makeaA grouped listbox. Firstly I did a ItemTemplate. Now I'm trying to group the data but I don't have any idea how to use that ItemTemplate. Could anybody help me a little?

My current listbox xaml

    <ListBox x:Name="kontakty" ItemsSource="{Binding kontakt}">
        <ListBox.GroupStyle>
            <GroupStyle HeaderStringFormat="Group">
                <GroupStyle.ContainerStyle>
                    <Style TargetType="{x:Type GroupItem}">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type GroupItem}">
                                    <StackPanel>
                                        <TextBlock Text="{Binding Path=Name}" Foreground="Red"/>
                                        <ComboBox ItemsSource="{Binding Path=Items}" DisplayMemberPath="Name"/>
                                    </StackPanel>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </GroupStyle.ContainerStyle>
            </GroupStyle>
        </ListBox.GroupStyle>
        <ListBox.ItemTemplate>
            //...............//
        </ListBox.ItemTemplate>
    </ListBox>

Upvotes: 1

Views: 1316

Answers (1)

Charlie Hopperson
Charlie Hopperson

Reputation: 415

Solution is adding ItemControl with this ItemTemplate to GroupStyle.

Upvotes: 1

Related Questions