14
14
namespace Microsoft . Toolkit . Uwp . UI . Controls
15
15
{
16
16
/// <summary>
17
- /// Display <see cref="MetadataUnit "/>s separated by bullets.
17
+ /// Display <see cref="MetadataItem "/>s separated by bullets.
18
18
/// </summary>
19
19
[ TemplatePart ( Name = TextContainerPart , Type = typeof ( TextBlock ) ) ]
20
20
public sealed class MetadataControl : Control
@@ -38,13 +38,22 @@ public sealed class MetadataControl : Control
38
38
new PropertyMetadata ( ", " , OnPropertyChanged ) ) ;
39
39
40
40
/// <summary>
41
- /// The DP to store the <see cref="MetadataUnits "/> property value.
41
+ /// The DP to store the <see cref="Items "/> property value.
42
42
/// </summary>
43
- public static readonly DependencyProperty MetadataUnitsProperty = DependencyProperty . Register (
44
- nameof ( MetadataUnits ) ,
45
- typeof ( IEnumerable < MetadataUnit > ) ,
43
+ public static readonly DependencyProperty ItemsProperty = DependencyProperty . Register (
44
+ nameof ( Items ) ,
45
+ typeof ( IEnumerable < MetadataItem > ) ,
46
46
typeof ( MetadataControl ) ,
47
- new PropertyMetadata ( null , OnMetadataUnitsChanged ) ) ;
47
+ new PropertyMetadata ( null , OnMetadataItemsChanged ) ) ;
48
+
49
+ /// <summary>
50
+ /// The DP to store the TextBlockStyle value.
51
+ /// </summary>
52
+ public static readonly DependencyProperty TextBlockStyleProperty = DependencyProperty . Register (
53
+ nameof ( TextBlockStyle ) ,
54
+ typeof ( Style ) ,
55
+ typeof ( MetadataControl ) ,
56
+ new PropertyMetadata ( null ) ) ;
48
57
49
58
private const string TextContainerPart = "TextContainer" ;
50
59
@@ -60,7 +69,7 @@ public MetadataControl()
60
69
}
61
70
62
71
/// <summary>
63
- /// Gets or sets the separator to display between the <see cref="MetadataUnit "/>.
72
+ /// Gets or sets the separator to display between the <see cref="MetadataItem "/>.
64
73
/// </summary>
65
74
public string Separator
66
75
{
@@ -78,13 +87,22 @@ public string AccessibleSeparator
78
87
}
79
88
80
89
/// <summary>
81
- /// Gets or sets he <see cref="MetadataUnit "/> to display in the control.
90
+ /// Gets or sets the <see cref="MetadataItem "/> to display in the control.
82
91
/// If it implements <see cref="INotifyCollectionChanged"/>, the control will automatically update itself.
83
92
/// </summary>
84
- public IEnumerable < MetadataUnit > MetadataUnits
93
+ public IEnumerable < MetadataItem > Items
94
+ {
95
+ get => ( IEnumerable < MetadataItem > ) GetValue ( ItemsProperty ) ;
96
+ set => SetValue ( ItemsProperty , value ) ;
97
+ }
98
+
99
+ /// <summary>
100
+ /// Gets or sets the <see cref="Style"/> to use on the inner <see cref="TextBlock"/> control.
101
+ /// </summary>
102
+ public Style TextBlockStyle
85
103
{
86
- get => ( IEnumerable < MetadataUnit > ) GetValue ( MetadataUnitsProperty ) ;
87
- set => SetValue ( MetadataUnitsProperty , value ) ;
104
+ get => ( Style ) GetValue ( TextBlockStyleProperty ) ;
105
+ set => SetValue ( TextBlockStyleProperty , value ) ;
88
106
}
89
107
90
108
/// <inheritdoc/>
@@ -94,7 +112,7 @@ protected override void OnApplyTemplate()
94
112
Update ( ) ;
95
113
}
96
114
97
- private static void OnMetadataUnitsChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
115
+ private static void OnMetadataItemsChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
98
116
{
99
117
var control = ( MetadataControl ) d ;
100
118
void OnCollectionChanged ( object sender , NotifyCollectionChangedEventArgs args ) => control . Update ( ) ;
@@ -127,7 +145,7 @@ private void Update()
127
145
128
146
_textContainer . Inlines . Clear ( ) ;
129
147
130
- if ( MetadataUnits is null )
148
+ if ( Items is null )
131
149
{
132
150
AutomationProperties . SetName ( _textContainer , string . Empty ) ;
133
151
NotifyLiveRegionChanged ( ) ;
@@ -136,7 +154,7 @@ private void Update()
136
154
137
155
Inline unitToAppend ;
138
156
var accessibleString = new StringBuilder ( ) ;
139
- foreach ( var unit in MetadataUnits )
157
+ foreach ( var unit in Items )
140
158
{
141
159
if ( _textContainer . Inlines . Count > 0 )
142
160
{
0 commit comments