@@ -609,5 +609,58 @@ public void VerifyUIElementsInItemsSource()
609
609
}
610
610
} ) ;
611
611
}
612
+
613
+ [ TestMethod ]
614
+ public void VerifyRepeaterDoesNotLeakItemContainers ( )
615
+ {
616
+ ObservableCollection < int > items = new ObservableCollection < int > ( ) ;
617
+ for ( int i = 0 ; i < 10 ; i ++ )
618
+ {
619
+ items . Add ( i ) ;
620
+ }
621
+
622
+ ItemsRepeater repeater = null ;
623
+
624
+ RunOnUIThread . Execute ( ( ) =>
625
+ {
626
+ var template = ( DataTemplate ) XamlReader . Load ( "<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' "
627
+ + "xmlns:local='using:MUXControlsTestApp.Samples'>"
628
+ + "<local:DisposableUserControl Number='{Binding}'/>"
629
+ + "</DataTemplate>" ) ;
630
+ Verify . IsNotNull ( template ) ;
631
+ Verify . AreEqual ( 0 , MUXControlsTestApp . Samples . DisposableUserControl . OpenItems , "Verify we start with 0 DisposableUserControl" ) ;
632
+
633
+ repeater = new ItemsRepeater ( ) {
634
+ ItemsSource = items ,
635
+ ItemTemplate = template ,
636
+ VerticalAlignment = VerticalAlignment . Top ,
637
+ HorizontalAlignment = HorizontalAlignment . Left
638
+ } ;
639
+
640
+ Content = repeater ;
641
+
642
+ } ) ;
643
+
644
+ IdleSynchronizer . Wait ( ) ;
645
+
646
+ RunOnUIThread . Execute ( ( ) =>
647
+ {
648
+
649
+ Verify . IsGreaterThanOrEqual ( MUXControlsTestApp . Samples . DisposableUserControl . OpenItems , 10 , "Verify we created at least 10 DisposableUserControl" ) ;
650
+
651
+ // Clear out the repeater and make sure everything gets cleaned up.
652
+ Content = null ;
653
+ repeater = null ;
654
+ } ) ;
655
+
656
+ IdleSynchronizer . Wait ( ) ;
657
+
658
+ GC . Collect ( ) ;
659
+ GC . WaitForPendingFinalizers ( ) ;
660
+ GC . Collect ( ) ;
661
+
662
+ Verify . AreEqual ( 0 , MUXControlsTestApp . Samples . DisposableUserControl . OpenItems , "Verify we cleaned up all the DisposableUserControl that were created" ) ;
663
+ }
664
+
612
665
}
613
666
}
0 commit comments