0

我有一个 GroupView。它保存联系人信息,除以每个联系人姓氏的第一个字母。

我从数据中创建了一个 CollectionViewSource (contactCVS)(这是正确创建的)。

然而数据出现了一个问题:第二组数据被截断了。

此 GridView 的 XAML 代码附在下面

            <GridView x:Name="contactsGroupGridView"
                      ItemsSource="{Binding Source={StaticResource contactCVS}}"
                      ItemTemplate="{StaticResource ContactListTemplate}"
                      SelectionMode="None"
                      IsItemClickEnabled="True"
                      Width="Auto"
                      Background="#FFF3EFE7"
                      Margin="0,0,50,0">

                <GridView.Header>
                    <StackPanel>
                        <Border Margin="0,5,0,0"
                                Width="220"
                                Height="120"
                                BorderThickness="2"
                                CornerRadius="2"
                                BorderBrush="Blue"
                                Tapped="BorderContactsTitle_Tapped"
                                Background="LightGray">
                            <Grid HorizontalAlignment="Center"
                                  VerticalAlignment="Center"
                                  Margin="0">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <TextBlock TextWrapping="Wrap"
                                           Text="Contacts"
                                           FontSize="32"
                                           HorizontalAlignment="Center"
                                           VerticalAlignment="Center"
                                           Foreground="Teal"
                                           FontWeight="Bold"
                                           Margin="0" />
                                <TextBlock TextWrapping="Wrap"
                                           Text=" View All"
                                           FontSize="16"
                                           HorizontalAlignment="Right"
                                           VerticalAlignment="Bottom"
                                           Foreground="Teal"
                                           FontWeight="Bold"
                                           Margin="0"
                                           Grid.Row="1" />
                            </Grid>
                        </Border>
                        <Image Height="200"
                               Width="200"
                               Source="ms-appx:///Resources/Images/Contacts.jpg"
                               HorizontalAlignment="Center"
                               Margin="0,50,0,0"
                               Stretch="UniformToFill" />
                        <TextBlock x:Name="ContactsGroupFullName"
                                   TextWrapping="Wrap"
                                   Text="{Binding FullName}"
                                   FontSize="24"
                                   FontWeight="Bold"
                                   FontFamily="Segoe UI"
                                   HorizontalAlignment="Center"
                                   VerticalAlignment="Center"
                                   Margin="0,30,0,0"
                                   Foreground="Brown" />
                        <StackPanel Margin="100,30,100,0"
                                    Orientation="Horizontal"
                                    Width="100"
                                    VerticalAlignment="Center"
                                    HorizontalAlignment="Center">
                            <Button x:Name="AddContactBtn"
                                    HorizontalAlignment="Center"
                                    VerticalAlignment="Center"
                                    Style="{StaticResource AddContactAppBarButtonStyle}"
                                    Click="AddContactBtn_Click" />
                        </StackPanel>
                    </StackPanel>
                </GridView.Header>

                <GridView.GroupStyle>
                    <GroupStyle>
                        <GroupStyle.HeaderTemplate>
                            <DataTemplate>
                                <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}"
                                      Margin="0">
                                    <TextBlock Text="{Binding Name}"
                                               Foreground="Teal"
                                               FontSize="40"
                                               Margin="0,20" />
                                </Grid>
                            </DataTemplate>
                        </GroupStyle.HeaderTemplate>

                        <GroupStyle.Panel>
                            <ItemsPanelTemplate>
                                <VariableSizedWrapGrid Margin="0,0,40,0"
                                                       MaximumRowsOrColumns="9" />
                            </ItemsPanelTemplate>
                        </GroupStyle.Panel>
                    </GroupStyle>
                </GridView.GroupStyle>

            </GridView>
4

1 回答 1

0

问题在于缺少 ItemsPanel 的定义......

问题解决了。

艾坦B

于 2012-09-23T00:44:30.820 回答