Skip to content

Commit f9197e0

Browse files
jfversluisPureWeen
authored andcommitted
Update Layout API Docs (#20247)
* Update Layout API Docs * Add more docs * Fix comment mistake * Add more docs
1 parent 50488a1 commit f9197e0

File tree

8 files changed

+319
-6
lines changed

8 files changed

+319
-6
lines changed

src/Controls/src/Core/Layout.cs

Lines changed: 153 additions & 1 deletion
Large diffs are not rendered by default.

src/Controls/src/Core/Layout/Layout.Android.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,19 @@ namespace Microsoft.Maui.Controls
77
{
88
public partial class Layout
99
{
10+
/// <summary>
11+
/// Maps the abstract InputTransparent property to the platform-specific implementations.
12+
/// </summary>
13+
/// <param name="handler">The associated handler.</param>
14+
/// <param name="layout">The associated <see cref="Layout"/> instance.</param>
1015
[Obsolete]
1116
public static void MapInputTransparent(LayoutHandler handler, Layout layout) { }
1217

18+
/// <summary>
19+
/// Maps the abstract InputTransparent property to the platform-specific implementations.
20+
/// </summary>
21+
/// <param name="handler">The associated handler.</param>
22+
/// <param name="layout">The associated <see cref="Layout"/> instance.</param>
1323
public static void MapInputTransparent(ILayoutHandler handler, Layout layout) { }
1424
}
1525
}

src/Controls/src/Core/Layout/Layout.Mapper.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ public abstract partial class Layout
1313
{
1414
}
1515

16+
/// <summary>
17+
/// The associated property mapper for this layout.
18+
/// </summary>
1619
[Obsolete("Use LayoutHandler.Mapper instead.")]
1720
public static IPropertyMapper<IView, IViewHandler> ControlsLayoutMapper = new PropertyMapper<IView, IViewHandler>(ControlsVisualElementMapper);
1821
}

src/Controls/src/Core/Layout/Layout.Standard.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,27 @@ namespace Microsoft.Maui.Controls
55
{
66
public partial class Layout
77
{
8+
/// <summary>
9+
/// Maps the abstract InputTransparent property to the platform-specific implementations.
10+
/// </summary>
11+
/// <param name="handler">The associated handler.</param>
12+
/// <param name="layout">The associated <see cref="Layout"/> instance.</param>
813
[Obsolete]
914
public static void MapInputTransparent(LayoutHandler handler, Layout layout) { }
1015

16+
/// <summary>
17+
/// Maps the abstract InputTransparent property to the platform-specific implementations.
18+
/// </summary>
19+
/// <param name="handler">The associated handler.</param>
20+
/// <param name="layout">The associated <see cref="Layout"/> instance.</param>
1121
[Obsolete]
1222
public static void MapInputTransparent(ILayoutHandler handler, Layout layout) { }
1323

24+
/// <summary>
25+
/// Maps the abstract InputTransparent property to the platform-specific implementations.
26+
/// </summary>
27+
/// <param name="handler">The associated handler.</param>
28+
/// <param name="layout">The associated <see cref="IView"/> instance.</param>
1429
[Obsolete]
1530
static void MapInputTransparent(IViewHandler handler, IView layout) { }
1631
}

src/Controls/src/Core/Layout/Layout.Tizen.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,19 @@ namespace Microsoft.Maui.Controls
55
{
66
public partial class Layout
77
{
8+
/// <summary>
9+
/// Maps the abstract InputTransparent property to the platform-specific implementations.
10+
/// </summary>
11+
/// <param name="handler">The associated handler.</param>
12+
/// <param name="layout">The associated <see cref="Layout"/> instance.</param>
813
[Obsolete]
914
public static void MapInputTransparent(LayoutHandler handler, Layout layout) { }
1015

16+
/// <summary>
17+
/// Maps the abstract InputTransparent property to the platform-specific implementations.
18+
/// </summary>
19+
/// <param name="handler">The associated handler.</param>
20+
/// <param name="layout">The associated <see cref="Layout"/> instance.</param>
1121
[Obsolete]
1222
public static void MapInputTransparent(ILayoutHandler handler, Layout layout) { }
1323
}

src/Controls/src/Core/Layout/Layout.Windows.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,19 @@ namespace Microsoft.Maui.Controls
66
{
77
public partial class Layout
88
{
9+
/// <summary>
10+
/// Maps the abstract InputTransparent property to the platform-specific implementations.
11+
/// </summary>
12+
/// <param name="handler">The associated handler.</param>
13+
/// <param name="layout">The associated <see cref="Layout"/> instance.</param>
914
[Obsolete]
1015
public static void MapInputTransparent(LayoutHandler handler, Layout layout) { }
1116

17+
/// <summary>
18+
/// Maps the abstract InputTransparent property to the platform-specific implementations.
19+
/// </summary>
20+
/// <param name="handler">The associated handler.</param>
21+
/// <param name="layout">The associated <see cref="Layout"/> instance.</param>
1222
[Obsolete]
1323
public static void MapInputTransparent(ILayoutHandler handler, Layout layout) { }
1424
}

src/Controls/src/Core/Layout/Layout.cs

Lines changed: 108 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99

1010
namespace Microsoft.Maui.Controls
1111
{
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>
1315
[ContentProperty(nameof(Children))]
1416
public abstract partial class Layout : View, Maui.ILayout, IList<IView>, IBindableLayout, IPaddingElement, IVisualTreeElement, ISafeAreaView, IInputTransparentContainerElement
1517
{
@@ -32,14 +34,21 @@ static ILayoutManager GetLayoutManagerFromFactory(Layout layout)
3234
// The actual backing store for the IViews in the ILayout
3335
readonly List<IView> _children = new();
3436

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>
3740
public IList<IView> Children => this;
3841

3942
IList IBindableLayout.Children => _children;
4043

44+
/// <summary>
45+
/// Gets the child object count in this layout.
46+
/// </summary>
4147
public int Count => _children.Count;
4248

49+
/// <summary>
50+
/// Gets whether this layout is readonly.
51+
/// </summary>
4352
public bool IsReadOnly => ((ICollection<IView>)_children).IsReadOnly;
4453

4554
public IView this[int index]
@@ -76,7 +85,10 @@ public IView this[int index]
7685
BindableProperty.Create(nameof(IsClippedToBounds), typeof(bool), typeof(Layout), false,
7786
propertyChanged: IsClippedToBoundsPropertyChanged);
7887

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>
8092
public bool IsClippedToBounds
8193
{
8294
get => (bool)GetValue(IsClippedToBoundsProperty);
@@ -96,17 +108,30 @@ static void IsClippedToBoundsPropertyChanged(BindableObject bindableObject, obje
96108
/// <summary>Bindable property for <see cref="Padding"/>.</summary>
97109
public static readonly BindableProperty PaddingProperty = PaddingElement.PaddingProperty;
98110

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>
100116
public Thickness Padding
101117
{
102118
get => (Thickness)GetValue(PaddingElement.PaddingProperty);
103119
set => SetValue(PaddingElement.PaddingProperty, value);
104120
}
105121

122+
/// <inheritdoc cref="ISafeAreaView.IgnoreSafeArea"/>
106123
public bool IgnoreSafeArea { get; set; }
107124

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>
108129
protected abstract ILayoutManager CreateLayoutManager();
109130

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>
110135
public IEnumerator<IView> GetEnumerator() => _children.GetEnumerator();
111136

112137
IEnumerator IEnumerable.GetEnumerator() => _children.GetEnumerator();
@@ -122,10 +147,16 @@ protected override void InvalidateMeasureOverride()
122147
base.InvalidateMeasureOverride();
123148
}
124149

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>
125154
public void Add(IView child)
126155
{
127156
if (child == null)
157+
{
128158
return;
159+
}
129160

130161
var index = _children.Count;
131162
_children.Add(child);
@@ -138,6 +169,9 @@ public void Add(IView child)
138169
OnAdd(index, child);
139170
}
140171

172+
/// <summary>
173+
/// Clears all child views from this layout.
174+
/// </summary>
141175
public void Clear()
142176
{
143177
for (int i = _children.Count - 1; i >= 0; i--)
@@ -152,38 +186,69 @@ public void Clear()
152186
OnClear();
153187
}
154188

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>
155194
public bool Contains(IView item)
156195
{
157196
return _children.Contains(item);
158197
}
159198

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>
160204
public void CopyTo(IView[] array, int arrayIndex)
161205
{
162206
_children.CopyTo(array, arrayIndex);
163207
}
164208

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>
165214
public int IndexOf(IView item)
166215
{
167216
return _children.IndexOf(item);
168217
}
169218

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>
170224
public void Insert(int index, IView child)
171225
{
172226
if (child == null)
227+
{
173228
return;
229+
}
174230

175231
_children.Insert(index, child);
176232

177233
if (child is Element element)
234+
{
178235
InsertLogicalChild(index, element);
236+
}
179237

180238
OnInsert(index, child);
181239
}
182240

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>
183246
public bool Remove(IView child)
184247
{
185248
if (child == null)
249+
{
186250
return false;
251+
}
187252

188253
var index = _children.IndexOf(child);
189254

@@ -197,6 +262,10 @@ public bool Remove(IView child)
197262
return true;
198263
}
199264

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>
200269
public void RemoveAt(int index)
201270
{
202271
if (index >= Count)
@@ -216,26 +285,50 @@ public void RemoveAt(int index)
216285
OnRemove(index, child);
217286
}
218287

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>
219293
protected virtual void OnAdd(int index, IView view)
220294
{
221295
NotifyHandler(nameof(ILayoutHandler.Add), index, view);
222296
}
223297

298+
/// <summary>
299+
/// Invoked when <see cref="Clear"/> is called and notifies the handler associated to this layout.
300+
/// </summary>
224301
protected virtual void OnClear()
225302
{
226303
Handler?.Invoke(nameof(ILayoutHandler.Clear));
227304
}
228305

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>
229311
protected virtual void OnRemove(int index, IView view)
230312
{
231313
NotifyHandler(nameof(ILayoutHandler.Remove), index, view);
232314
}
233315

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>
234321
protected virtual void OnInsert(int index, IView view)
235322
{
236323
NotifyHandler(nameof(ILayoutHandler.Insert), index, view);
237324
}
238325

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>
239332
protected virtual void OnUpdate(int index, IView view, IView oldView)
240333
{
241334
NotifyHandler(nameof(ILayoutHandler.Update), index, view);
@@ -266,10 +359,20 @@ public Graphics.Size CrossPlatformArrange(Graphics.Rect bounds)
266359
return LayoutManager.ArrangeChildren(bounds);
267360
}
268361

362+
/// <summary>Bindable property for <see cref="CascadeInputTransparent"/>.</summary>
269363
public static readonly BindableProperty CascadeInputTransparentProperty =
270364
BindableProperty.Create(nameof(CascadeInputTransparent), typeof(bool), typeof(Layout), true,
271365
propertyChanged: OnCascadeInputTransparentPropertyChanged);
272366

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>
273376
public bool CascadeInputTransparent
274377
{
275378
get => (bool)GetValue(CascadeInputTransparentProperty);

src/Controls/src/Core/Layout/Layout.iOS.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,19 @@ namespace Microsoft.Maui.Controls
55
{
66
public partial class Layout
77
{
8+
/// <summary>
9+
/// Maps the abstract InputTransparent property to the platform-specific implementations.
10+
/// </summary>
11+
/// <param name="handler">The associated handler.</param>
12+
/// <param name="layout">The associated <see cref="Layout"/> instance.</param>
813
[Obsolete]
914
public static void MapInputTransparent(LayoutHandler handler, Layout layout) { }
1015

16+
/// <summary>
17+
/// Maps the abstract InputTransparent property to the platform-specific implementations.
18+
/// </summary>
19+
/// <param name="handler">The associated handler.</param>
20+
/// <param name="layout">The associated <see cref="Layout"/> instance.</param>
1121
[Obsolete]
1222
public static void MapInputTransparent(ILayoutHandler handler, Layout layout) { }
1323
}

0 commit comments

Comments
 (0)