public void ContainerFromIndex_ClearHostPanel () { // If we clear the panel, then we can no longer link the container to the // control. Do we check container.Parent and retrieve the TemplateOwner from there? var c = new ItemsControl (); c.Items.Add (new object ()); CreateAsyncTest (c, () => { var container = c.ItemContainerGenerator.ContainerFromIndex (0); var panel = c.GetChild<ItemsPresenter> (0).GetChild<Panel> (0); panel.Children.Clear (); Assert.AreSame (container, c.ItemContainerGenerator.ContainerFromIndex (0), "#1"); }); }