我创建了一个列表框并在列表中插入项目。但是,一旦我返回并再次转到同一页面,将不会清除并重新加载数据。它将直接加载数据。这会导致数据出现两次。
这是我的编码部分。
<ListBox x:Name="LocationList"
HorizontalContentAlignment="Center"
ItemContainerStyle="{StaticResource ListBoxItemStretchContentStyle}"
Visibility="{Binding CurrentState,
Converter={StaticResource StateToNormalVisibilityConverter}}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0">
<TextBlock x:Name="PurchaseName" Text="{Binding Name}" Style="{StaticResource LongListSelectorGroupHeaderLetterTileStyle}"/>
<TextBlock x:Name="Description" Text="{Binding Description}" Style="{StaticResource PhoneTextSubtleStyle}"/>
</StackPanel>
<Grid Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="Price"
Text="{Binding Price}"
Visibility="{Binding Purchased,
Converter={StaticResource PurchasedBoolToVisibilityConverter}}"
VerticalAlignment="Center"/>
<Button Grid.Column="1"
VerticalAlignment="Center"
Content="Buy"
Visibility="{Binding Purchased,
Converter={StaticResource PurchasedBoolToVisibilityConverter}}"
Click="Buy_Location"/>
</Grid>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
当我加载到该特定页面时如何清除数据???