WinRT ControlTemplate ItemsPanel

Posted by user1427149 on Stack Overflow See other posts from Stack Overflow or by user1427149
Published on 2012-05-30T22:37:45Z Indexed on 2012/05/30 22:40 UTC
Read the original article Hit count: 381

Filed under:
|
|

I'm new to WinRT and am trying to create a standard gridview which has a group heading with a number of tiles beneath it. That bit is easy. I'm trying to modify it so that beneath the grid of tiles I can also add a footer using the containers style:

    <GridView
        x:Name="itemGridView"
        AutomationProperties.AutomationId="ItemGridView"
        AutomationProperties.Name="Grouped Items"
        Margin="116,0,40,46"
        ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
        ItemTemplate="{StaticResource Project200x200ItemTemplate}"                
        SelectionMode="None"
        IsItemClickEnabled="True"
        ItemClick="ItemView_ItemClick">

        <GridView.ItemsPanel>
            <ItemsPanelTemplate>
                <VirtualizingStackPanel Orientation="Horizontal"/>
            </ItemsPanelTemplate>
        </GridView.ItemsPanel>

        <GridView.GroupStyle>
            <GroupStyle>
                <GroupStyle.HeaderTemplate>
                    <DataTemplate>
                        <Grid Margin="1,0,0,6">
                            <Button
                                AutomationProperties.Name="Group Title"
                                Content="{Binding Name}"
                                Click="Header_Click"
                                Style="{StaticResource TextButtonStyle}" 
                                FontWeight="{Binding IsSelected, ConverterParameter=FontWeight, Converter={StaticResource BooleanToFontWeightConverter}}"
                               />
                        </Grid>
                    </DataTemplate>
                </GroupStyle.HeaderTemplate>
                <GroupStyle.Panel>                           
                    <ItemsPanelTemplate>
                        <VariableSizedWrapGrid Background="Red"  Orientation="Vertical" Margin="0,0,40,0" />
                    </ItemsPanelTemplate>
                </GroupStyle.Panel>

                <GroupStyle.ContainerStyle>
                    <Style TargetType="GroupItem">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate>
                                    <StackPanel>
                                        <ContentPresenter/>
                                        <ItemsPresenter/>
                                        <TextBlock Text="*** End of group ***"/>
                                    </StackPanel>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </GroupStyle.ContainerStyle>

            </GroupStyle>
        </GridView.GroupStyle>               
    </GridView>

This almost works but after adding the container style, the grid of tiles no longer shows... the group header and 'End of group' textblock is showing, but I've lost the tile grid.

Can anyone spot what I'm doing wrong...?

© Stack Overflow or respective owner

Related posts about winrt

Related posts about controltemplate