forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageToggleButton.xaml.cs
More file actions
60 lines (55 loc) · 2.3 KB
/
ImageToggleButton.xaml.cs
File metadata and controls
60 lines (55 loc) · 2.3 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
//-----------------------------------------------------------------------
// <copyright file="ImageToggleButton.xaml.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
// <summary>
// Implements ImageToggleButton.
// </summary>
//-----------------------------------------------------------------------
namespace Microsoft.PowerShell.Commands.ShowCommandInternal
{
using System.Diagnostics.CodeAnalysis;
using System.Windows;
using System.Windows.Automation;
/// <summary>
/// Toggle button with images to represent enabled and disabled states
/// </summary>
[SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes", Justification = "Required by XAML")]
public partial class ImageToggleButton : ImageButtonBase
{
/// <summary>
/// Value indicating the button is checked
/// </summary>
public static readonly DependencyProperty IsCheckedProperty =
DependencyProperty.Register("IsChecked", typeof(bool), typeof(ImageToggleButton));
/// <summary>
/// Initializes a new instance of the ImageToggleButton class.
/// </summary>
public ImageToggleButton()
{
InitializeComponent();
this.Loaded += new System.Windows.RoutedEventHandler(this.ImageButton_Loaded);
}
/// <summary>
/// Gets or sets a value indicating whether the button is checked
/// </summary>
public bool IsChecked
{
get { return (bool)GetValue(ImageToggleButton.IsCheckedProperty); }
set { SetValue(ImageToggleButton.IsCheckedProperty, value); }
}
/// <summary>
/// Copies the automation id from the parent control to the inner button
/// </summary>
/// <param name="sender">event sender</param>
/// <param name="e">event arguments</param>
private void ImageButton_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
object thisAutomationId = this.GetValue(AutomationProperties.AutomationIdProperty);
if (thisAutomationId != null)
{
this.toggleInnerButton.SetValue(AutomationProperties.AutomationIdProperty, thisAutomationId);
}
}
}
}