Skip to content

Commit 66f33aa

Browse files
pictosdavidbritch
andauthored
LazyView Docs (#78)
* added lazyView docs * added LazyView into the TOC file * fixed typo * other fix * Use alphabetical order. * Copy edits. * Update lazyview.md Co-authored-by: David Britch <[email protected]>
1 parent 0b62f71 commit 66f33aa

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

docs/TOC.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@
110110
href: views/docklayout.md
111111
- name: "Expander"
112112
href: views/expander.md
113+
- name: "LazyView"
114+
href: views/lazyview.md
113115
- name: "MediaElement"
114116
href: views/mediaelement.md
115117
- name: "RangeSlider"
@@ -123,4 +125,4 @@
123125
- name: "UniformGrid"
124126
href: views/uniformgrid.md
125127
- name: "Troubleshooting"
126-
href: troubleshooting.md
128+
href: troubleshooting.md

docs/views/lazyview.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
title: "Xamarin Community Toolkit LazyView"
3+
description: "This article explains how to use LazyView, which lets you delay the initialization of a View."
4+
author: pedro
5+
ms.author: joverslu
6+
ms.date: 02/11/2021
7+
---
8+
9+
# Xamarin Community Toolkit LazyView
10+
11+
The `LazyView` control allows you to delay the initialization of a `View`. You need to provide the type of the `View` that you want to be rendered, using the `x:TypeArguments` XAML namespace attribute, and handle its initialization using the `LoadViewAsync` method. The `IsLoaded` property can be examined to determine when the `LazyView` is loaded.
12+
13+
## Syntax
14+
15+
```xaml
16+
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
17+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
18+
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
19+
x:Class="MyLittleApp.MainPage"
20+
xmlns:local="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages.Views.TabView">
21+
22+
<StackLayout>
23+
24+
<xct:LazyView x:TypeArguments="local:LazyTestView" IsLoaded = "{Binding IsLoaded}" />
25+
26+
</StackLayout>
27+
28+
</ContentPage>
29+
```
30+
31+
## Properties
32+
33+
|Property |Type |Description |
34+
|---------|---------|---------|
35+
| IsLoaded | bool| Gets the loaded status of the `LazyView`. |
36+
37+
## Methods
38+
39+
|Property |Return Type |Description |
40+
|---------|---------|---------|
41+
| LoadViewAsync | ValueTask| Initialize the `View`. |
42+
| Dispose | void | Cleans up the `View`, if required. |
43+
44+
## Sample
45+
46+
[LazyView sample page Source](https://github.com/xamarin/XamarinCommunityToolkit/blob/develop/samples/XCT.Sample/Pages/Views/TabView/LazyTabPage.xaml)
47+
48+
You can see this in action in the [Xamarin Community Toolkit Sample App](https://github.com/xamarin/XamarinCommunityToolkit).

0 commit comments

Comments
 (0)