异常:
{System.ArgumentException: Value does not fall within the expected range.}
{System.Collections.ListDictionaryInternal}
这个发生在我逐条删除LongListSelector数据是发生的, MainLongListSelector.ItemsSource 是和ObservableCollection绑定以便动态删除,可是当我每次删除到8,9条时就会发生如上异常。
我的xmal:
<phone:LongListSelector x:Name="MainLongListSelector" Margin="0,0,-12,0" ItemsSource="{Binding DuplicateContacts}">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel>
<Grid>
<TextBlock Text="{Binding DisplayName}"
Foreground="Black"
TextTrimming="WordEllipsis"
Margin="30,10,50,10"
VerticalAlignment="Center"
Style="{StaticResource PhoneTextLargeStyle}"/>
<Button x:Name="Detail"
HorizontalAlignment="Right" BorderThickness="0"
VerticalAlignment="Bottom"
Margin="0,10,20,10"
Click="Detail_Click">
<Button.Background>
<ImageBrush Stretch="Uniform" ImageSource="/Images/rightwards.png"/>
</Button.Background>
</Button>
</Grid>
<toolkit:ContextMenuService.ContextMenu>
<toolkit:ContextMenu IsZoomEnabled="True">
<toolkit:MenuItem Header="Delete" CommandParameter="{Binding}"
Click="MenuItem_Click"/>
</toolkit:ContextMenu>