views:

3608

answers:

3

I have a ListView that displays sales orders, and groups them by status. In WinForms I had a footer at the bottom of each group that displayed the Total sale price for each group, and I would like to do the same in WPF.

I have figured out how to group the orders, but I can't figure out how to create a footer.

This is my current group style:

<ListView.GroupStyle>
            <GroupStyle HidesIfEmpty="True">
                <GroupStyle.HeaderTemplate>
                    <DataTemplate>
                        <!--CollectionViewGroup.Name will be assigned the value of Status for that group.-->
                        <!--http://stackoverflow.com/questions/639809/how-do-i-group-items-in-a-wpf-listview--&gt;
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Column="0" Text="{Binding Path=Name}" HorizontalAlignment="Left" FontWeight="Bold"  Foreground="Black"/>
                            <Line Grid.Column="1" Stroke="Black" X2="500" Fill="Black" VerticalAlignment="Center" />
                        </Grid>
                    </DataTemplate>
                </GroupStyle.HeaderTemplate>
            </GroupStyle>
        </ListView.GroupStyle>
+13  A: 
bendewey
Thank you very much for putting this much effort into your answer. It really helped.
Russ
I'm glad it worked for you. I learn some things myself writing it.
bendewey
Wow really great.
Sauron
A: 

This trick is great but I'm having a problem.

You see, application users have the possibility to update the value (which is User.Total in your example) through a modal window.

When there is only one item in the Group, both the User Total displayed and the sum are properly updated. But when there are multiple items in the group, only the User Total is updated (through binding) but the Converter that's supposed to make the sum (in your example : TotalSumConverter) is not even called!

Do you have any idea where it could come from? Should I use some kind of a trigger to make sure the Converter is called when there is a modification in the items?

Hi Francois, can I suggest you would get a lot better response by starting a new question. Most people on stackoverflow will not answer a question in an answer. use either a new question or a comment.Thanks.
David Waters
A: 

Do you have an example of this project in VB I tried to recreate it in VB but im getting a error on this line

An object of the type "WpfApplication1.TotalSumConverter" cannot be applied to a property that expects the type "System.Windows.Data.IValueConverter".

I cant seem to figure it out

bigshop