public void VisualAncestorsTest() { var grid = new Grid(); var button = new Button(); grid.Children.Add(button); var parent = VisualTreeHelper.GetParent(button); Assert.AreEqual(grid, parent); Assert.AreEqual(grid, button.VisualAncestors().Single()); }