I'm creating a WPF TimeCard app using the MVVM design pattern, and I'm trying to display the sum (total) hours the user has clocked in grouped by each day. I have a ListView with all of the TimeCard data broken into groups using the following XAML:
<ListView.GroupStyle>
<GroupStyle ContainerStyle="{StaticResource GroupItemStyle}">
<GroupStyle.HeaderTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Name, StringFormat=\{0:D\}}" FontWeight="Bold"/>
<TextBlock Text=" (" FontWeight="Bold"/>
<!-- This needs to display the sum of the hours -->
<TextBlock Text="{Binding ???}" FontWeight="Bold"/>
<TextBlock Text=" hours)" FontWeight="Bold"/>
</StackPanel>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</ListView.GroupStyle>
Is this even possible? At first I thought I would create a partial class of the CollectionViewGroup and add my own properties. But I'm not sure this will even work. Perhaps there is a better solution... any suggestions?