Couldn't think of any better way than hide-and-seek using DataTrigger
! The following works.
<ControlTemplate TargetType="GroupItem">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock x:Name="normalHeader" Text="{Binding Name}" FontWeight="Bold"/>
<Grid x:Name="singleItem" Visibility="Collapsed" Margin="0 0 10 0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="200"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="100"/>
</Grid.ColumnDefinitions>
<TextBlock>
<Run Text="{Binding Name, Mode=OneWay}" FontWeight="Bold"/>
<Run Text=" - "/>
<Run Text="{Binding Items[0].Space}"/>
</TextBlock>
<TextBlock Grid.Column="1" Text="{Binding Items[0].Date, StringFormat='dd MMMM, yyyy'}" TextAlignment="Center"/>
<cc:NumReport Grid.Column="2" Text="{Binding Items[0].Security}"/>
<cc:NumReport Grid.Column="3" Text="{Binding Items[0].Rent}"/>
<cc:NumReport Grid.Column="4" Text="{Binding Items[0].Due}"/>
</Grid>
<ItemsPresenter Grid.Row="1" Margin="10 0 0 0" x:Name="itemsPresenter"/>
<ContentPresenter x:Name="footer" Grid.Row="2" Content="{Binding Items, Converter={StaticResource GSC}}"/>
</Grid>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding Items.Count}" Value="1">
<Setter Property="Visibility" Value="Collapsed" TargetName="normalHeader"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="itemsPresenter"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="footer"/>
<Setter Property="Visibility" Value="Visible" TargetName="singleItem"/>
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
The problem is I can't select group header! Is it possible to select the Line/Header
on click? Is it possible to sort these by number of spaces occupied?