forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExpanderButton.cs
More file actions
65 lines (58 loc) · 2.79 KB
/
Copy pathExpanderButton.cs
File metadata and controls
65 lines (58 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//-----------------------------------------------------------------------
// <copyright file="ExpanderButton.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Microsoft.Management.UI.Internal
{
using System.Windows;
using System.Windows.Automation;
using System.Windows.Automation.Peers;
using System.Windows.Controls.Primitives;
/// <summary>
/// Represents a toggle button used to expand or collapse elements.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes")]
public partial class ExpanderButton : ToggleButton
{
/// <summary>
/// Initializes a new instance of the <see cref="ExpanderButton" /> class.
/// </summary>
public ExpanderButton()
{
// This constructor intentionally left blank
}
/// <summary>
/// Invoked whenever the effective value of any dependency property on this <see cref="ExpanderButton"/> has been updated. The specific dependency property that changed is reported in the arguments parameter. Overrides <see cref="FrameworkElement.OnPropertyChanged"/>.
/// </summary>
/// <param name="e">The event data that describes the property that changed, as well as old and new values.</param>
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
{
base.OnPropertyChanged(e);
if (e.Property == ExpanderButton.IsCheckedProperty)
{
this.OnIsCheckedChanged(e);
}
}
/// <summary>
/// Called when the <see cref="ToggleButton.IsChecked"/> property changes.
/// </summary>
/// <param name="args">The event data that describes the property that changed, as well as old and new values.</param>
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);
}
}
}
}
}