9
9
10
10
namespace Microsoft . Maui . Controls
11
11
{
12
- /// <include file="../../../docs/Microsoft.Maui.Controls/Layout.xml" path="Type[@FullName='Microsoft.Maui.Controls.Layout']/Docs/*" />
12
+ /// <summary>
13
+ /// Base class for layouts that allow you to arrange and group UI controls in your application.
14
+ /// </summary>
13
15
[ ContentProperty ( nameof ( Children ) ) ]
14
16
public abstract partial class Layout : View , Maui . ILayout , IList < IView > , IBindableLayout , IPaddingElement , IVisualTreeElement , ISafeAreaView , IInputTransparentContainerElement
15
17
{
@@ -32,14 +34,21 @@ static ILayoutManager GetLayoutManagerFromFactory(Layout layout)
32
34
// The actual backing store for the IViews in the ILayout
33
35
readonly List < IView > _children = new ( ) ;
34
36
35
- // This provides a Children property for XAML
36
- /// <include file="../../../docs/Microsoft.Maui.Controls/Layout.xml" path="//Member[@MemberName='Children']/Docs/*" />
37
+ /// <summary>
38
+ /// Gets the child objects contained in this layout.
39
+ /// </summary>
37
40
public IList < IView > Children => this ;
38
41
39
42
IList IBindableLayout . Children => _children ;
40
43
44
+ /// <summary>
45
+ /// Gets the child object count in this layout.
46
+ /// </summary>
41
47
public int Count => _children . Count ;
42
48
49
+ /// <summary>
50
+ /// Gets whether this layout is readonly.
51
+ /// </summary>
43
52
public bool IsReadOnly => ( ( ICollection < IView > ) _children ) . IsReadOnly ;
44
53
45
54
public IView this [ int index ]
@@ -76,7 +85,10 @@ public IView this[int index]
76
85
BindableProperty . Create ( nameof ( IsClippedToBounds ) , typeof ( bool ) , typeof ( Layout ) , false ,
77
86
propertyChanged : IsClippedToBoundsPropertyChanged ) ;
78
87
79
- /// <include file="../../../docs/Microsoft.Maui.Controls/Layout.xml" path="//Member[@MemberName='IsClippedToBounds']/Docs/*" />
88
+ /// <summary>
89
+ /// Gets or sets a value which determines if the layout should clip its children to its bounds.
90
+ /// The default value is <see langword="false"/>.
91
+ /// </summary>
80
92
public bool IsClippedToBounds
81
93
{
82
94
get => ( bool ) GetValue ( IsClippedToBoundsProperty ) ;
@@ -96,17 +108,30 @@ static void IsClippedToBoundsPropertyChanged(BindableObject bindableObject, obje
96
108
/// <summary>Bindable property for <see cref="Padding"/>.</summary>
97
109
public static readonly BindableProperty PaddingProperty = PaddingElement . PaddingProperty ;
98
110
99
- /// <include file="../../../docs/Microsoft.Maui.Controls/Layout.xml" path="//Member[@MemberName='Padding']/Docs/*" />
111
+ /// <summary>
112
+ /// Gets or sets the inner padding of the layout.
113
+ /// The default value is a <see cref="Thickness"/> with all values set to 0.
114
+ /// </summary>
115
+ /// <remarks>The padding is the space between the bounds of a layout and the bounding region into which its children should be arranged into.</remarks>
100
116
public Thickness Padding
101
117
{
102
118
get => ( Thickness ) GetValue ( PaddingElement . PaddingProperty ) ;
103
119
set => SetValue ( PaddingElement . PaddingProperty , value ) ;
104
120
}
105
121
122
+ /// <inheritdoc cref="ISafeAreaView.IgnoreSafeArea"/>
106
123
public bool IgnoreSafeArea { get ; set ; }
107
124
125
+ /// <summary>
126
+ /// Creates a manager object that can measure this layout and arrange its children.
127
+ /// </summary>
128
+ /// <returns>An object that implements <see cref="ILayoutManager"/> that manages this layout.</returns>
108
129
protected abstract ILayoutManager CreateLayoutManager ( ) ;
109
130
131
+ /// <summary>
132
+ /// Returns an enumerator that lists all of the children in this layout.
133
+ /// </summary>
134
+ /// <returns>A <see cref="IEnumerator{T}"/> of type <see cref="IView"/> with all the children in this layout.</returns>
110
135
public IEnumerator < IView > GetEnumerator ( ) => _children . GetEnumerator ( ) ;
111
136
112
137
IEnumerator IEnumerable . GetEnumerator ( ) => _children . GetEnumerator ( ) ;
@@ -122,10 +147,16 @@ protected override void InvalidateMeasureOverride()
122
147
base . InvalidateMeasureOverride ( ) ;
123
148
}
124
149
150
+ /// <summary>
151
+ /// Adds a child view to the end of this layout.
152
+ /// </summary>
153
+ /// <param name="child">The child view to add.</param>
125
154
public void Add ( IView child )
126
155
{
127
156
if ( child == null )
157
+ {
128
158
return ;
159
+ }
129
160
130
161
var index = _children . Count ;
131
162
_children . Add ( child ) ;
@@ -138,6 +169,9 @@ public void Add(IView child)
138
169
OnAdd ( index , child ) ;
139
170
}
140
171
172
+ /// <summary>
173
+ /// Clears all child views from this layout.
174
+ /// </summary>
141
175
public void Clear ( )
142
176
{
143
177
for ( int i = _children . Count - 1 ; i >= 0 ; i -- )
@@ -152,38 +186,69 @@ public void Clear()
152
186
OnClear ( ) ;
153
187
}
154
188
189
+ /// <summary>
190
+ /// Determines if the specified child view is contained in this layout.
191
+ /// </summary>
192
+ /// <param name="item">The child view for which to determine if it is contained in this layout.</param>
193
+ /// <returns><see langword="true"/> if <paramref name="item"/> exists in this layout, otherwise <see langword="false"/>.</returns>
155
194
public bool Contains ( IView item )
156
195
{
157
196
return _children . Contains ( item ) ;
158
197
}
159
198
199
+ /// <summary>
200
+ /// Copies the child views to the specified array.
201
+ /// </summary>
202
+ /// <param name="array">The target array to copy the child views to.</param>
203
+ /// <param name="arrayIndex">The index at which the copying needs to start.</param>
160
204
public void CopyTo ( IView [ ] array , int arrayIndex )
161
205
{
162
206
_children . CopyTo ( array , arrayIndex ) ;
163
207
}
164
208
209
+ /// <summary>
210
+ /// Gets the index of a specified child view.
211
+ /// </summary>
212
+ /// <param name="item">The child view of which to determine the index.</param>
213
+ /// <returns>The index of the specified view, if the view was not found this will return <c>-1</c>.</returns>
165
214
public int IndexOf ( IView item )
166
215
{
167
216
return _children . IndexOf ( item ) ;
168
217
}
169
218
219
+ /// <summary>
220
+ /// Inserts a child view at the specified index.
221
+ /// </summary>
222
+ /// <param name="index">The index at which to specify the child view.</param>
223
+ /// <param name="child">The child view to insert.</param>
170
224
public void Insert ( int index , IView child )
171
225
{
172
226
if ( child == null )
227
+ {
173
228
return ;
229
+ }
174
230
175
231
_children . Insert ( index , child ) ;
176
232
177
233
if ( child is Element element )
234
+ {
178
235
InsertLogicalChild ( index , element ) ;
236
+ }
179
237
180
238
OnInsert ( index , child ) ;
181
239
}
182
240
241
+ /// <summary>
242
+ /// Removes a child view.
243
+ /// </summary>
244
+ /// <param name="child">The child view to remove.</param>
245
+ /// <returns><see langword="true"/> if the view was removed successfully, otherwise <see langword="false"/>.</returns>
183
246
public bool Remove ( IView child )
184
247
{
185
248
if ( child == null )
249
+ {
186
250
return false ;
251
+ }
187
252
188
253
var index = _children . IndexOf ( child ) ;
189
254
@@ -197,6 +262,10 @@ public bool Remove(IView child)
197
262
return true ;
198
263
}
199
264
265
+ /// <summary>
266
+ /// Removes a child view at the specified index.
267
+ /// </summary>
268
+ /// <param name="index">The index at which to remove the child view.</param>
200
269
public void RemoveAt ( int index )
201
270
{
202
271
if ( index >= Count )
@@ -216,26 +285,50 @@ public void RemoveAt(int index)
216
285
OnRemove ( index , child ) ;
217
286
}
218
287
288
+ /// <summary>
289
+ /// Invoked when <see cref="Add(IView)"/> is called and notifies the handler associated to this layout.
290
+ /// </summary>
291
+ /// <param name="index">The index at which the child view was inserted.</param>
292
+ /// <param name="view">The child view which was inserted.</param>
219
293
protected virtual void OnAdd ( int index , IView view )
220
294
{
221
295
NotifyHandler ( nameof ( ILayoutHandler . Add ) , index , view ) ;
222
296
}
223
297
298
+ /// <summary>
299
+ /// Invoked when <see cref="Clear"/> is called and notifies the handler associated to this layout.
300
+ /// </summary>
224
301
protected virtual void OnClear ( )
225
302
{
226
303
Handler ? . Invoke ( nameof ( ILayoutHandler . Clear ) ) ;
227
304
}
228
305
306
+ /// <summary>
307
+ /// Invoked when <see cref="Insert(int, IView)"/> is called and notifies the handler associated to this layout.
308
+ /// </summary>
309
+ /// <param name="index">The index at which the child view was inserted.</param>
310
+ /// <param name="view">The child view which was inserted.</param>
229
311
protected virtual void OnRemove ( int index , IView view )
230
312
{
231
313
NotifyHandler ( nameof ( ILayoutHandler . Remove ) , index , view ) ;
232
314
}
233
315
316
+ /// <summary>
317
+ /// Invoked when <see cref="RemoveAt(int)"/> is called and notifies the handler associated to this layout.
318
+ /// </summary>
319
+ /// <param name="index">The index at which the child view was removed.</param>
320
+ /// <param name="view">The child view which was removed.</param>
234
321
protected virtual void OnInsert ( int index , IView view )
235
322
{
236
323
NotifyHandler ( nameof ( ILayoutHandler . Insert ) , index , view ) ;
237
324
}
238
325
326
+ /// <summary>
327
+ /// Invoked when <see cref="this[int]"/> is called and notifies the handler associated to this layout.
328
+ /// </summary>
329
+ /// <param name="index">The index at which the child view was updated.</param>
330
+ /// <param name="view">The new child view which was added at <paramref name="index"/>.</param>
331
+ /// <param name="oldView">The previous child view which was at <paramref name="index"/>.</param>
239
332
protected virtual void OnUpdate ( int index , IView view , IView oldView )
240
333
{
241
334
NotifyHandler ( nameof ( ILayoutHandler . Update ) , index , view ) ;
@@ -266,10 +359,20 @@ public Graphics.Size CrossPlatformArrange(Graphics.Rect bounds)
266
359
return LayoutManager . ArrangeChildren ( bounds ) ;
267
360
}
268
361
362
+ /// <summary>Bindable property for <see cref="CascadeInputTransparent"/>.</summary>
269
363
public static readonly BindableProperty CascadeInputTransparentProperty =
270
364
BindableProperty . Create ( nameof ( CascadeInputTransparent ) , typeof ( bool ) , typeof ( Layout ) , true ,
271
365
propertyChanged : OnCascadeInputTransparentPropertyChanged ) ;
272
366
367
+ /// <summary>
368
+ /// Gets or sets a value that controls whether child elements
369
+ /// inherit the input transparency of this layout when the tranparency is <see langword="true"/>.
370
+ /// </summary>
371
+ /// <value>
372
+ /// <see langword="true" /> to cause child elements to inherit the input transparency of this layout,
373
+ /// when this layout's <see cref="VisualElement.InputTransparent" /> property is <see langword="true" />.
374
+ /// <see langword="false" /> to cause child elements to ignore the input tranparency of this layout.
375
+ /// </value>
273
376
public bool CascadeInputTransparent
274
377
{
275
378
get => ( bool ) GetValue ( CascadeInputTransparentProperty ) ;
0 commit comments