|
28 | 28 | using System.Collections.ObjectModel; |
29 | 29 | using System.Threading; |
30 | 30 | using System.Collections.Generic; |
| 31 | +using Windows.UI.Xaml.Tests.MUXControls.ApiTests.RepeaterTests.Common.Mocks; |
31 | 32 |
|
32 | 33 | namespace Windows.UI.Xaml.Tests.MUXControls.ApiTests.RepeaterTests |
33 | 34 | { |
@@ -145,6 +146,35 @@ public void ValidateGetSetItemsSource() |
145 | 146 | }); |
146 | 147 | } |
147 | 148 |
|
| 149 | + [TestMethod] |
| 150 | + public void VerifyClearingItemsSourceClearsElements() |
| 151 | + { |
| 152 | + var data = new ObservableCollection<string>(Enumerable.Range(0, 4).Select(i => "Item #" + i)); |
| 153 | + var mapping = (List<ContentControl>)null; |
| 154 | + |
| 155 | + RunOnUIThread.Execute(() => |
| 156 | + { |
| 157 | + mapping = Enumerable.Range(0, data.Count).Select(i => new ContentControl { Width = 40, Height = 40 }).ToList(); |
| 158 | + |
| 159 | + var dataSource = MockItemsSource.CreateDataSource(data, supportsUniqueIds: false); |
| 160 | + var elementFactory = MockElementFactory.CreateElementFactory(mapping); |
| 161 | + ItemsRepeater repeater = new ItemsRepeater(); |
| 162 | + repeater.ItemsSource = dataSource; |
| 163 | + repeater.ItemTemplate = elementFactory; |
| 164 | + // This was an issue only for NonVirtualizing layouts |
| 165 | + repeater.Layout = new MyCustomNonVirtualizingStackLayout(); |
| 166 | + Content = repeater; |
| 167 | + Content.UpdateLayout(); |
| 168 | + |
| 169 | + repeater.ItemsSource = null; |
| 170 | + }); |
| 171 | + |
| 172 | + foreach(var item in mapping) |
| 173 | + { |
| 174 | + Verify.IsNull(item.Parent); |
| 175 | + } |
| 176 | + } |
| 177 | + |
148 | 178 | [TestMethod] |
149 | 179 | public void ValidateGetSetBackground() |
150 | 180 | { |
|
0 commit comments