Home > other >  how could i create grouped listbox in WPF .net 6 with multi items and custom design in group header
how could i create grouped listbox in WPF .net 6 with multi items and custom design in group header

Time:03-11

i tried already every thing i could think about , and searched a lot for a slution

thats my current XMAL PART of the group header i'm trying to figgure

            <ListBox.GroupStyle>
                <GroupStyle >


                    <GroupStyle.HeaderTemplate>

                        <DataTemplate>
                            <Grid>
                                <TextBlock x:Name="GrpDate" FontWeight="Bold" FontSize="14" Text="{Binding Name}" TextAlignment="Right" Grid.Row="0"/>
                                <TextBlock x:Name="GrpNote" FontWeight="Bold" FontSize="14" Text="{Binding Note }" TextAlignment="Right" Grid.Row="1"/>
                                <TextBlock x:Name="GrpNote1" FontWeight="Bold" FontSize="14" Text="{Binding orderid }" TextAlignment="Right" Grid.Row="1"/>
                            </Grid>
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>


                </GroupStyle>
            </ListBox.GroupStyle>

my data is bind to SQL server, and i tried using collection views

CodePudding user response:

The DataContext of a GroupItem has an Items property that contains all grouped items so you should be able to bind to the Note and orderid properties of an item in the group like this:

<TextBlock x:Name="GrpDate" ... Text="{Binding Name}" />
<TextBlock x:Name="GrpNote" ... Text="{Binding Items[0].Note }" />
<TextBlock x:Name="GrpNote1" ... Text="{Binding Items[0].orderid }" />
                        
  • Related