我如何在 WPF .net 6 中创建包含多个项目和自定义设计的分组列表框 header
how could i create grouped listbox in WPF .net 6 with multi items and custom design in group header
我已经尝试了所有我能想到的东西,并且搜索了很多解决方案
这就是我目前在小组中的 XMAL 部分 header 我正在计算
<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>
我的数据绑定到 SQL 服务器,我尝试使用 collection 视图
GroupItem
的 DataContext
有一个包含所有分组项目的 Items
属性,因此您应该能够绑定到 Note
和orderid
组中某项的属性如下:
<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 }" />
我已经尝试了所有我能想到的东西,并且搜索了很多解决方案
这就是我目前在小组中的 XMAL 部分 header 我正在计算
<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>
我的数据绑定到 SQL 服务器,我尝试使用 collection 视图
GroupItem
的 DataContext
有一个包含所有分组项目的 Items
属性,因此您应该能够绑定到 Note
和orderid
组中某项的属性如下:
<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 }" />