//----------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------- namespace Microsoft.Management.UI.Internal { using System.Windows; using System.Windows.Automation; using System.Windows.Automation.Peers; using System.Windows.Controls.Primitives; /// /// Represents a toggle button used to expand or collapse elements. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes")] public partial class ExpanderButton : ToggleButton { /// /// Initializes a new instance of the class. /// public ExpanderButton() { // This constructor intentionally left blank } /// /// Invoked whenever the effective value of any dependency property on this has been updated. The specific dependency property that changed is reported in the arguments parameter. Overrides . /// /// The event data that describes the property that changed, as well as old and new values. protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e) { base.OnPropertyChanged(e); if (e.Property == ExpanderButton.IsCheckedProperty) { this.OnIsCheckedChanged(e); } } /// /// Called when the property changes. /// /// The event data that describes the property that changed, as well as old and new values. protected void OnIsCheckedChanged(DependencyPropertyChangedEventArgs args) { if (AutomationPeer.ListenerExists(AutomationEvents.PropertyChanged)) { var peer = UIElementAutomationPeer.CreatePeerForElement(this); if (peer != null) { var oldValue = (bool?)args.OldValue; var newValue = (bool?)args.NewValue; peer.RaisePropertyChangedEvent( ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty, (oldValue == true) ? ExpandCollapseState.Expanded : ExpandCollapseState.Collapsed, (newValue == true) ? ExpandCollapseState.Expanded : ExpandCollapseState.Collapsed); } } } } }