A strange problem in windows 8 MSDN Examples

Source: Internet
Author: User

Http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.media.animation.repositionthemetransition.aspx

 1 <Button Content="Remove Rectangle" Click="RemoveButton_Click"/> 2  3 <ItemsControl Grid.Row="1" x:Name="rectangleItems"> 4     <ItemsControl.ItemContainerTransitions> 5         <TransitionCollection> 6              7             <!-- Without this, there would be no animation when items  8                  are removed. --> 9             <RepositionThemeTransition/>10         </TransitionCollection>11     </ItemsControl.ItemContainerTransitions>12     <ItemsControl.ItemsPanel>13         <ItemsPanelTemplate>14             <WrapGrid Height="400"/>15         </ItemsPanelTemplate>16     </ItemsControl.ItemsPanel>17     18     <!-- All these rectangles are just to demonstrate how the items19          in the grid re-flow into position when one of the child items20          are removed. -->21     <ItemsControl.Items>22         <Rectangle Fill="Red" Width="100" Height="100" Margin="10"/>23         <Rectangle Fill="Red" Width="100" Height="100" Margin="10"/>24         <Rectangle Fill="Red" Width="100" Height="100" Margin="10"/>25         <Rectangle Fill="Red" Width="100" Height="100" Margin="10"/>26         <Rectangle Fill="Red" Width="100" Height="100" Margin="10"/>27         <Rectangle Fill="Red" Width="100" Height="100" Margin="10"/>28         <Rectangle Fill="Red" Width="100" Height="100" Margin="10"/>29         <Rectangle Fill="Red" Width="100" Height="100" Margin="10"/>30         <Rectangle Fill="Red" Width="100" Height="100" Margin="10"/>31     </ItemsControl.Items>32 </ItemsControl>

 

1 private void RemoveButton_Click(object sender, RoutedEventArgs e)2 {3     if (rectangleItems.Items.Count > 0)4         rectangleItems.Items.RemoveAt(0);5 }

Each time you click a button, a Red Square is deleted. However, when only one block is deleted, the error "Value does not fall within the expected range." is returned when you click the delete button ."
A strange reminder is that there is another one. Why can't it be deleted? Cannot rectangleItems. Items be blank? Call rectangleItems. items. clear () method to delete rectangleItems. all Items in the Items, the response is normal. After trying again, <ItemsControl. the blocks in Items> are directly deleted and can still be run.

I wonder if anyone has encountered a similar problem. Why?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.