void BasedOn_FindName_Core(bool useTwice) { Style s1 = new Style(typeof(Grid)); Style s2 = new Style(typeof(Grid)); Style basedon = new Style(typeof(Grid)); s1.SetValue(FrameworkElement.NameProperty, "s1"); s2.SetValue(FrameworkElement.NameProperty, "s2"); basedon.SetValue(FrameworkElement.NameProperty, "basedon"); s1.BasedOn = basedon; if (useTwice) s2.BasedOn = basedon; TestPanel.Children.Add(new Grid { Name = "Grid2", Style = s2 }); TestPanel.Children.Add(new Grid { Name = "Grid1", Style = s1 }); Assert.IsInstanceOfType<Style>(TestPanel.FindName("s1"), "#1"); Assert.IsInstanceOfType<Style>(TestPanel.FindName("s2"), "#2"); if (useTwice) Assert.IsNull(TestPanel.FindName("basedon"), "#3"); else Assert.AreSame(s1.BasedOn, TestPanel.FindName("basedon"), "#4"); }