public void LogicalAncestorsTest() { var grid = new Grid(); var button = new Button(); grid.Children.Add(button); var parent = LogicalTreeHelper.GetParent(button); Assert.AreEqual(grid, parent); Assert.AreEqual(grid, button.LogicalAncestors().Single()); }