locked
How to make GroupStyle.HeaderTemplate to fit the size (Height) of rows under it

    Question

  • I am working on this GridView project in which i need to set the Group size (Height) according to the number of rows under that group,(See the image)

    In the GroupStyle.HeaderTemplate I am using the DataTemplate with VariableSizedWarpGrid to dynamically set size of Group Header(VariableSizedWarpGrid) but it would not work as it sets height of all Groups in Gridview, while i am looking to set it based on number of Rows under each group.

                    <GridView.GroupStyle>
                        <GroupStyle HidesIfEmpty="True" >

                            <GroupStyle.HeaderTemplate>
                                <DataTemplate>


                                        <VariableSizedWrapGrid Name="GroupedGrid" Background="#FF1F497D" Width="200" Height="100"
                                                           HorizontalChildrenAlignment="Center"  VerticalChildrenAlignment="Center" >


                                            <TextBlock Text='{Binding Key}' Name="txtGroupName" Foreground="{StaticResource ApplicationForegroundThemeBrush}" 
                                                       TextWrapping="NoWrap" FontFamily="Global User Interface"  />



                                    </VariableSizedWrapGrid>


                                </DataTemplate>
                            </GroupStyle.HeaderTemplate>

                        </GroupStyle>
                    </GridView.GroupStyle>

    and GridView is bound to a  <CollectionViewSource x:Name="cvsEvents" IsSourceGrouped="True" /> which has a key bound to group/header

    Please help this is an urgent issue

    Tuesday, June 10, 2014 4:05 PM

Answers

  • Hi Barlas,

    Could it possible to calculate the amount of the group items and then use the convertor to set the height for VariableSizeWrapGrid height?

    For instance the number of HH Framing is 2, the height of the group header should be (100*2+some space)

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Wednesday, June 11, 2014 5:30 AM
    Moderator