Skip to content

Commit

Permalink
Use compiled bindings (#2735)
Browse files Browse the repository at this point in the history
* Use compiled bindings.

* Edit.
  • Loading branch information
davidbritch authored Jan 17, 2025
1 parent 050cd80 commit 91efe45
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions docs/android/platform-specifics/listview-fast-scrolling.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "ListView fast scrolling on Android"
description: "This article explains how to consume the .NET MAUI Android platform-specific that enables fast scrolling through data in a ListView."
ms.date: 04/05/2022
ms.date: 01/16/2025
---

# ListView fast scrolling on Android
Expand All @@ -10,7 +10,9 @@ This .NET Multi-platform App UI (.NET MAUI) Android platform-specific is used to

```xaml
<ContentPage ...
xmlns:android="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific;assembly=Microsoft.Maui.Controls">
xmlns:android="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific;assembly=Microsoft.Maui.Controls"
xmlns:local="clr-namespace:PlatformSpecifics"
x:DataType="local:ListViewViewModel">
<StackLayout>
...
<ListView ItemsSource="{Binding GroupedEmployees}"
Expand All @@ -29,9 +31,9 @@ Alternatively, it can be consumed from C# using the fluent API:
using Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific;
...

var listView = new Microsoft.Maui.Controls.ListView { IsGroupingEnabled = true, ... };
listView.SetBinding(ItemsView<Cell>.ItemsSourceProperty, "GroupedEmployees");
listView.GroupDisplayBinding = new Binding("Key");
var listView = new Microsoft.Maui.Controls.ListView { IsGroupingEnabled = true, ItemTemplate = personDataTemplate };
listView.SetBinding(ItemsView<Cell>.ItemsSourceProperty, static (ListViewViewModel vm) => vm.GroupedEmployees); // .NET 9+ compiled binding
listView.GroupDisplayBinding = Binding.Create(static (Grouping<char, Person> g) => g.Key); // .NET 9+ compiled binding
listView.On<Microsoft.Maui.Controls.PlatformConfiguration.Android>().SetIsFastScrollEnabled(true);
```

Expand Down

0 comments on commit 91efe45

Please sign in to comment.