views:

173

answers:

0

I have XAML code with a grouped ListView that looks like the following:

<ListView ItemsSource="{Binding}" Name="ContactList">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <controls:ContactItemControl />
                </DataTemplate>
            </ListView.ItemTemplate>
            <ListView.GroupStyle>
                <GroupStyle>
                    <GroupStyle.HeaderTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Name}"/>
                                <TextBlock Text=" Contacts: " />
                                <TextBlock Name="OnlineTextBlock"/>
                                <TextBlock Text="/" />
                                <TextBlock Text="{Binding ItemCount}"/>
                             </StackPanel>
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>
                </GroupStyle>
            </ListView.GroupStyle>
        </ListView>

In my code behind, I need a way to access the Items and ItemsCount of each group in the list view. How do I go about doing this? I need to populate the OnlineTextBlock with the number of contacts online - so I need to sum a variable that is located within each contact.