C# ItemControl样式
创建ItemsControl并将其分组时,例如:C# ItemControl样式,c#,wpf,xaml,C#,Wpf,Xaml,创建ItemsControl并将其分组时,例如: <CollectionViewSource x:Key="items" Source="{Binding Items}"> <CollectionViewSource.GroupDescriptions> <swd:PropertyGroupDescription PropertyName="User"/> </CollectionViewSourc
<CollectionViewSource x:Key="items" Source="{Binding Items}">
<CollectionViewSource.GroupDescriptions>
<swd:PropertyGroupDescription PropertyName="User"/>
</CollectionViewSource.GroupDescriptions>
</CollectionViewSource>
<ItemsControl ItemsSource="{Binding Source={StaticResource items}}"
<GroupStyle.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"</TextBlock>
</DataTemplate>
</GroupStyle.HeaderTemplate>
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding item}"></TextBlock>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
但我不希望项目在新行中,我希望它与组名在同一行中,如下所示:
Group name
item1, item2, item3 etc.
Group name item1, item2, item3 etc.
怎么做?我知道可能需要创建样式,但我不知道具体需要更改哪个属性。您可能需要使用
GroupItem.ContainerStyle
覆盖GroupItem
的模板