Skip to content

Commit 7b2f4f9

Browse files
authored
Update README.md
1 parent e9d82b6 commit 7b2f4f9

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

README.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ For section template selectors, subclass `AdapterSectionDataTemplateSelector`.
229229

230230
All templates can contain a single `IView`, or alternatively you can use `VirtualViewCell` to wrap your view.
231231

232-
The `VirtualViewCell` adds some additional bindable properties that are useful for adapting your views for things like separators and selection state:
232+
The `VirtualViewCell`'s `ResourceDictionary` will contain a set of values which are are useful for adapting your views for things like separators and selection state:
233233

234234
- int SectionIndex
235235
- int ItemIndex
@@ -244,6 +244,8 @@ The `VirtualViewCell` adds some additional bindable properties that are useful f
244244
- bool IsNotFirstItemInSection
245245
- bool IsSelected
246246

247+
> NOTE: These are also available as properties on `VirtualViewCell` itself, since it implements `IPositionInfo`
248+
247249
You can access these properties from your templates. Here's an example of displaying an item separator using these properties, as well as changing the background color based on the selection state and a converter:
248250

249251
```xml
@@ -252,8 +254,7 @@ You can access these properties from your templates. Here's an example of displ
252254
xmlns:xct="clr-namespace:Microsoft.Maui.Controls;assembly=VirtualListView"
253255
xmlns="http://xamarin.com/schemas/2014/forms"
254256
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
255-
x:Class="VirtualListViewSample.GenericViewCell"
256-
x:Name="self">
257+
x:Class="VirtualListViewSample.GenericViewCell">
257258
<xct:VirtualViewCell>
258259
<StackLayout
259260
Spacing="0"
@@ -263,7 +264,8 @@ You can access these properties from your templates. Here's an example of displ
263264
HorizontalOptions="FillAndExpand"
264265
HeightRequest="1"
265266
BackgroundColor="#f8f8f8"
266-
IsVisible="{Binding Source={x:Reference self}, Path=IsNotFirstItemInSection}" />
267+
IsVisible="{DynamicResource IsNotFirstItemInSection}" <!-- Use the automatic property -->
268+
/>
267269

268270
<Border Background="#f0f0f0" StrokeShape="{RoundedRectangle CornerRadius=14}" Margin="10,5,10,5" Padding="10">
269271
<Label Text="{Binding TrackName}" />
@@ -274,7 +276,7 @@ You can access these properties from your templates. Here's an example of displ
274276
</xct:VirtualViewCell>
275277
```
276278

277-
Notice the `xct:VirtualViewCell` has a `x:Name="self"` name. This allows you to reference the object and its bindable properties as the example shows inside the `BoxView`'s visibility: `IsVisible="{Binding Source={x:Reference self}, Path=IsNotFirstItemInSection}"`.
279+
Notice the `IsVisible="{DynamicResource IsNotFirstItemInSection}"` references a resource which has been automatically populated by the `VirtualViewCell`.
278280

279281
## Selection
280282

@@ -288,8 +290,22 @@ In the future there will be bindable properties and maybe a way to cancel a sele
288290
## Refreshing
289291

290292
Pull to refresh is enabled for iOS/MacCatalyst and Android. WindowsAppSDK does not have the equivalent feature so there is no support for it.
291-
292293
You can use the `RefreshCommand` or subscribe to the `OnRefresh` event to perform your logic while the refresh indicator displays.
294+
You must set `IsRefreshEnabled` to true to enable the gesture.
295+
You can also set the `RefreshAccentColor` to change the color of the refresh indicator.
296+
297+
## Empty View
298+
299+
If your adapter has <= 1 section and no items, an empty view can be displayed automatically:
300+
301+
```xaml
302+
<vlv:VirtualListView.EmptyView>
303+
<Grid>
304+
<Label HorizontalOptions="Center" VerticalOptions="Center" Text="EMPTY" />
305+
</Grid>
306+
</vlv:VirtualListView.EmptyView>
307+
```
308+
293309

294310
## Scrolled
295311

0 commit comments

Comments
 (0)