/// <summary> /// When overridden in a derived class, returns a <see cref="Style"/> based on custom logic. /// </summary> /// <param name="item">The content.</param> /// <param name="container">The element to which the style will be applied.</param> /// <returns> /// Returns an application-specific style to apply; otherwise, null. /// </returns> public override Style SelectStyle(object item, DependencyObject container) { Expander expander = container as Expander; if (null == expander) { return(null); } string styleKey = "ExpanderGroupStyle"; XmlElement element = item as XmlElement; if (null != element) { if (null != element.Attributes["UseAlternateStyle"]) { bool useAlternateStyle; if (bool.TryParse(element.Attributes["UseAlternateStyle"].Value, out useAlternateStyle)) { if (useAlternateStyle) { styleKey = "ExpanderGroupAlternateStyle"; } } } } return(expander.FindResource(styleKey) as Style); }
public void ToggleButtonTemplateTest() { // for code coverage UITester.Dispatcher.Invoke(() => { var template = (ControlTemplate)testExpander.FindResource("PlusExpanderToggleButtonTemplate"); testExpander.ToggleButtonTemplate = template; Assert.AreEqual(testExpander.ToggleButtonTemplate, template); testExpander.ToggleButtonTemplate = null; Assert.IsNull(testExpander.ToggleButtonTemplate); testExpander.ToggleButtonTemplate = template; Assert.AreEqual(testExpander.ToggleButtonTemplate, template); }); }