6
6
using Microsoft . Toolkit . Uwp . UI . Controls ;
7
7
using Windows . UI . Xaml . Automation ;
8
8
using Windows . UI . Xaml . Automation . Peers ;
9
+ using Windows . UI . Xaml . Automation . Provider ;
9
10
using Windows . UI . Xaml . Controls ;
10
11
11
12
namespace Microsoft . Toolkit . Uwp . UI . Automation . Peers
12
13
{
13
14
/// <summary>
14
15
/// Defines a framework element automation peer for the <see cref="TokenizingTextBox"/> control.
15
16
/// </summary>
16
- public class TokenizingTextBoxAutomationPeer : ListViewBaseAutomationPeer
17
+ public class TokenizingTextBoxAutomationPeer : ListViewBaseAutomationPeer , IValueProvider
17
18
{
18
19
/// <summary>
19
20
/// Initializes a new instance of the <see cref="TokenizingTextBoxAutomationPeer"/> class.
@@ -26,6 +27,14 @@ public TokenizingTextBoxAutomationPeer(TokenizingTextBox owner)
26
27
{
27
28
}
28
29
30
+ /// <summary>Gets a value that indicates whether the value of a control is read-only.</summary>
31
+ /// <returns>**true** if the value is read-only; **false** if it can be modified.</returns>
32
+ public bool IsReadOnly => ! this . OwningTokenizingTextBox . IsEnabled ;
33
+
34
+ /// <summary>Gets the value of the control.</summary>
35
+ /// <returns>The value of the control.</returns>
36
+ public string Value => this . OwningTokenizingTextBox . Text ;
37
+
29
38
private TokenizingTextBox OwningTokenizingTextBox
30
39
{
31
40
get
@@ -34,6 +43,13 @@ private TokenizingTextBox OwningTokenizingTextBox
34
43
}
35
44
}
36
45
46
+ /// <summary>Sets the value of a control.</summary>
47
+ /// <param name="value">The value to set. The provider is responsible for converting the value to the appropriate data type.</param>
48
+ public void SetValue ( string value )
49
+ {
50
+ this . OwningTokenizingTextBox . Text = value ;
51
+ }
52
+
37
53
/// <summary>
38
54
/// Called by GetClassName that gets a human readable name that, in addition to AutomationControlType,
39
55
/// differentiates the control represented by this AutomationPeer.
@@ -50,8 +66,8 @@ protected override string GetClassNameCore()
50
66
/// <returns>
51
67
/// Returns the first of these that is not null or empty:
52
68
/// - Value returned by the base implementation
53
- /// - Name of the owning Carousel
54
- /// - Carousel class name
69
+ /// - Name of the owning TokenizingTextBox
70
+ /// - TokenizingTextBox class name
55
71
/// </returns>
56
72
protected override string GetNameCore ( )
57
73
{
@@ -62,12 +78,22 @@ protected override string GetNameCore()
62
78
}
63
79
64
80
name = AutomationProperties . GetName ( this . OwningTokenizingTextBox ) ;
65
- if ( ! string . IsNullOrEmpty ( name ) )
66
- {
67
- return name ;
68
- }
81
+ return ! string . IsNullOrEmpty ( name ) ? name : base . GetNameCore ( ) ;
82
+ }
69
83
70
- return base . GetNameCore ( ) ;
84
+ /// <summary>
85
+ /// Gets the control pattern that is associated with the specified Windows.UI.Xaml.Automation.Peers.PatternInterface.
86
+ /// </summary>
87
+ /// <param name="patternInterface">A value from the Windows.UI.Xaml.Automation.Peers.PatternInterface enumeration.</param>
88
+ /// <returns>The object that supports the specified pattern, or null if unsupported.</returns>
89
+ protected override object GetPatternCore ( PatternInterface patternInterface )
90
+ {
91
+ return patternInterface switch
92
+ {
93
+ PatternInterface . Value => this ,
94
+ PatternInterface . Selection => this ,
95
+ _ => base . GetPatternCore ( patternInterface )
96
+ } ;
71
97
}
72
98
73
99
/// <summary>
@@ -97,4 +123,4 @@ protected override IList<AutomationPeer> GetChildrenCore()
97
123
return peers ;
98
124
}
99
125
}
100
- }
126
+ }
0 commit comments