1

私は以下を持っていますGridView

<GridView
            x:Name="itemGridView" 
            AutomationProperties.AutomationId="ItemsGridView"
            AutomationProperties.Name="Items"
            TabIndex="1"
            Grid.RowSpan="2"
            Padding="116,136,116,46"
            SelectionMode="Single"
            IsSwipeEnabled="false"
            Visibility="Collapsed">

                <GridView.ItemTemplate>
                    <DataTemplate>
                        <!--<Border BorderBrush="DarkSeaGreen" BorderThickness="1">-->
                        <Grid Background="{Binding objBackgroundColor}" Opacity="1" Width="400" Height="80">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="30"></RowDefinition>
                                <RowDefinition Height="*"></RowDefinition>
                            </Grid.RowDefinitions>
                            <Grid Grid.Row="0">
                                <TextBlock Text="{Binding objCustomTestPaper.Name}" TextWrapping="Wrap"  FontWeight="SemiBold" VerticalAlignment="Top" Foreground="{Binding objForegroundColor}" Style="{StaticResource TitleTextStyle}" FontSize="20" MaxHeight="25"  Margin="10,5,10,0" />
                            </Grid>
                            <Grid Grid.Row="1">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="auto"></ColumnDefinition>
                                    <ColumnDefinition Width="*"></ColumnDefinition>
                                    <ColumnDefinition Width="120"></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <!--<Image Grid.Column="0" Height="35" VerticalAlignment="Center" HorizontalAlignment="Center" Source="Assets/paper.png"></Image>-->
                                <StackPanel Grid.Column="0" Margin="5,7,0,0">
                                    <callisto:Rating  FontStretch="SemiCondensed" ItemCount="5" Value="{Binding objCustomTestPaper.TestRating}" FontWeight="Light" VerticalAlignment="Bottom"  Margin="0,2,5,1" Background="Transparent"  HorizontalAlignment="Left" Foreground="{Binding objForegroundColor}" IsHitTestVisible="False" FontSize="12" >
                                    </callisto:Rating>
                                    <StackPanel  Orientation="Horizontal" HorizontalAlignment="Left">
                                        <TextBlock Text="Attempted by others:" Margin="4,0,0,0" FontSize="12" FontWeight="Light" Foreground="{Binding objForegroundColor}"></TextBlock>
                                        <TextBlock Text="{Binding objCustomTestPaper.AttemptCount}" FontWeight="SemiBold" Margin="5,0,0,0" FontSize="12" Foreground="{Binding objForegroundColor}"></TextBlock>
                                        <TextBlock Text="times" Margin="3,0,0,0" FontSize="12" FontWeight="Light" Foreground="{Binding objForegroundColor}"></TextBlock>
                                    </StackPanel>
                                </StackPanel>
                                <StackPanel VerticalAlignment="Stretch" Grid.Column="2" Margin="0,0,0,0" >
                                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center">
                                        <TextBlock Text="Time:" FontSize="16" Foreground="{Binding objForegroundColor}" VerticalAlignment="Bottom" FontWeight="SemiLight"></TextBlock>
                                        <TextBlock Text="{Binding strTestDuration}" Margin="5,0,0,0" FontSize="18" VerticalAlignment="Bottom" Foreground="{Binding objForegroundColor}" FontWeight="SemiLight"></TextBlock>
                                    </StackPanel>
                                    <StackPanel  Margin="0,2,0,0" Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center">
                                        <TextBlock Text="Points:" FontSize="16" Margin="0,0,0,0" VerticalAlignment="Bottom" Foreground="{Binding objForegroundColor}" FontWeight="SemiLight"></TextBlock>
                                        <TextBlock Text="{Binding objCustomTestPaper.TotalMarks}" Margin="5,0,0,0" VerticalAlignment="Bottom" FontSize="18" Foreground="{Binding objForegroundColor}" FontWeight="SemiLight"></TextBlock>
                                    </StackPanel>
                                </StackPanel>
                            </Grid>
                        </Grid>
                    </DataTemplate>
                </GridView.ItemTemplate>

            </GridView>

正常に動作し、データを正常にロードしますが、戻るボタンを押すと、データはメモリに残り(使用できなくなります)、ページにアクセスするたびに増加し続けます。GridViewwhenOnNavigationFrom(,)メソッドが呼び出されたときにアイテムをクリアする方法がわかりません。使用しようとしていますobjGridView.Items.Clear()が、HRXXXX例外が発生します。

4

0 に答える 0