I wrote the following example and works well. You can check to see is there any differences from yours.
<Window
x:Class="ForumProjects.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ForumProjects"
Width="800" Height="600">
<Window.Resources>
<ObjectDataProvider x:Key="devices" ObjectType="{x:Type local:DeviceCollection}"/>
<CollectionViewSource x:Key='src' Source="{Binding Source={StaticResource devices}}">
<CollectionViewSource.GroupDescriptions>
<PropertyGroupDescription PropertyName="Description"/>
</CollectionViewSource.GroupDescriptions>
</CollectionViewSource>
</Window.Resources>
<ListView ItemsSource="{Binding Source={StaticResource src}}">
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Margin" Value="0,0,0,5"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<Expander IsExpanded="True" BorderBrush="#FFA4B97F" BorderThickness="0,0,0,1">
<Expander.Header>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<DockPanel Margin="10,0,0,0">
<TextBlock FontWeight="Bold" Text="{Binding Path=Name}"/>
</DockPanel>
<DockPanel Grid.Row="1" Margin="10,0,0,0">
<TextBlock FontWeight="Bold" Text="{Binding Path=ItemCount}"/>
</DockPanel>
</Grid>
</Expander.Header>
<Expander.Content>
<ItemsPresenter/>
</Expander.Content>
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</ListView.GroupStyle>
<ListView.View>
<GridView>
<GridViewColumn Header="ID" Width="50" DisplayMemberBinding="{Binding ID}"/>
<GridViewColumn Header="Address" Width="150" DisplayMemberBinding="{Binding Address}"/>
</GridView>
</ListView.View>
</ListView>
</Window>
publicclassDevice
{
publicint ID { get; set; }
publicstring Address { get; set; }
publicstring Description { get; set; }
}
publicclassDeviceCollection : ObservableCollection<Device>
{
public DeviceCollection()
{
this.Add(newDevice() { ID = 1, Address = "Address 1", Description = "Desc A" });
this.Add(newDevice() { ID = 2, Address = "Address 2", Description = "Desc B" });
this.Add(newDevice() { ID = 3, Address = "Address 3", Description = "Desc A" });
this.Add(newDevice() { ID = 4, Address = "Address 4", Description = "Desc B" });
}
}
Best Regards,
Wei Zhou