diff --git a/Maui/VirtualizingRecyclingScrollView/App.xaml b/Maui/VirtualizingRecyclingScrollView/App.xaml
new file mode 100644
index 0000000..0cedc1b
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/App.xaml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Maui/VirtualizingRecyclingScrollView/App.xaml.cs b/Maui/VirtualizingRecyclingScrollView/App.xaml.cs
new file mode 100644
index 0000000..144b50a
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/App.xaml.cs
@@ -0,0 +1,14 @@
+namespace VirtualizingRecyclingScrollView;
+
+public partial class App : Application
+{
+ public App()
+ {
+ InitializeComponent();
+ }
+
+ protected override Window CreateWindow(IActivationState? activationState)
+ {
+ return new Window(new AppShell());
+ }
+}
diff --git a/Maui/VirtualizingRecyclingScrollView/AppShell.xaml b/Maui/VirtualizingRecyclingScrollView/AppShell.xaml
new file mode 100644
index 0000000..9170de7
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/AppShell.xaml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
diff --git a/Maui/VirtualizingRecyclingScrollView/AppShell.xaml.cs b/Maui/VirtualizingRecyclingScrollView/AppShell.xaml.cs
new file mode 100644
index 0000000..45d12bd
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/AppShell.xaml.cs
@@ -0,0 +1,9 @@
+namespace VirtualizingRecyclingScrollView;
+
+public partial class AppShell : Shell
+{
+ public AppShell()
+ {
+ InitializeComponent();
+ }
+}
diff --git a/Maui/VirtualizingRecyclingScrollView/CellModel.cs b/Maui/VirtualizingRecyclingScrollView/CellModel.cs
new file mode 100644
index 0000000..97d64fb
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/CellModel.cs
@@ -0,0 +1,35 @@
+
+using System.ComponentModel;
+
+namespace VirtualizingRecyclingScrollView;
+
+public class CellModel : INotifyPropertyChanged
+{
+ public Key key;
+
+ private string text;
+
+ private Color color;
+
+ public event PropertyChangedEventHandler? PropertyChanged;
+
+ public string Text
+ {
+ get => this.text;
+ set
+ {
+ this.text = value;
+ this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Text)));
+ }
+ }
+
+ public Color Color
+ {
+ get => this.color;
+ set
+ {
+ this.color = value;
+ this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Color)));
+ }
+ }
+}
\ No newline at end of file
diff --git a/Maui/VirtualizingRecyclingScrollView/Key.cs b/Maui/VirtualizingRecyclingScrollView/Key.cs
new file mode 100644
index 0000000..d0434bf
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/Key.cs
@@ -0,0 +1,13 @@
+namespace VirtualizingRecyclingScrollView;
+
+public struct Key
+{
+ public int x;
+ public int y;
+
+ public Key(int x, int y)
+ {
+ this.x = x;
+ this.y = y;
+ }
+}
\ No newline at end of file
diff --git a/Maui/VirtualizingRecyclingScrollView/MainPage.xaml b/Maui/VirtualizingRecyclingScrollView/MainPage.xaml
new file mode 100644
index 0000000..b644003
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/MainPage.xaml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Maui/VirtualizingRecyclingScrollView/MainPage.xaml.cs b/Maui/VirtualizingRecyclingScrollView/MainPage.xaml.cs
new file mode 100644
index 0000000..47fc9b2
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/MainPage.xaml.cs
@@ -0,0 +1,10 @@
+namespace VirtualizingRecyclingScrollView;
+
+public partial class MainPage : ContentPage
+{
+ public MainPage()
+ {
+ this.BindingContext = TrackingModel.Instance;
+ InitializeComponent();
+ }
+}
diff --git a/Maui/VirtualizingRecyclingScrollView/MauiProgram.cs b/Maui/VirtualizingRecyclingScrollView/MauiProgram.cs
new file mode 100644
index 0000000..794f49d
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/MauiProgram.cs
@@ -0,0 +1,33 @@
+using Microsoft.Extensions.Logging;
+using Microsoft.Maui.Handlers;
+
+namespace VirtualizingRecyclingScrollView;
+
+public static class MauiProgram
+{
+ public static MauiApp CreateMauiApp()
+ {
+ var builder = MauiApp.CreateBuilder();
+ builder
+ .UseMauiApp()
+ .ConfigureMauiHandlers(handlers =>
+ {
+ ViewHandler.ViewCommandMapper.ModifyMapping(nameof(IView.InvalidateMeasure), (layout, handler, args, current) =>
+ {
+ // Comment this out to stop layout invalidation...
+ current?.Invoke(layout, handler, args);
+ });
+ })
+ .ConfigureFonts(fonts =>
+ {
+ fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
+ fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
+ });
+
+#if DEBUG
+ builder.Logging.AddDebug();
+#endif
+
+ return builder.Build();
+ }
+}
diff --git a/Maui/VirtualizingRecyclingScrollView/Platforms/Android/AndroidManifest.xml b/Maui/VirtualizingRecyclingScrollView/Platforms/Android/AndroidManifest.xml
new file mode 100644
index 0000000..bdec9b5
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/Platforms/Android/AndroidManifest.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Maui/VirtualizingRecyclingScrollView/Platforms/Android/MainActivity.cs b/Maui/VirtualizingRecyclingScrollView/Platforms/Android/MainActivity.cs
new file mode 100644
index 0000000..7500d07
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/Platforms/Android/MainActivity.cs
@@ -0,0 +1,10 @@
+using Android.App;
+using Android.Content.PM;
+using Android.OS;
+
+namespace VirtualizingRecyclingScrollView;
+
+[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, LaunchMode = LaunchMode.SingleTop, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
+public class MainActivity : MauiAppCompatActivity
+{
+}
diff --git a/Maui/VirtualizingRecyclingScrollView/Platforms/Android/MainApplication.cs b/Maui/VirtualizingRecyclingScrollView/Platforms/Android/MainApplication.cs
new file mode 100644
index 0000000..f89a9e1
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/Platforms/Android/MainApplication.cs
@@ -0,0 +1,15 @@
+using Android.App;
+using Android.Runtime;
+
+namespace VirtualizingRecyclingScrollView;
+
+[Application]
+public class MainApplication : MauiApplication
+{
+ public MainApplication(IntPtr handle, JniHandleOwnership ownership)
+ : base(handle, ownership)
+ {
+ }
+
+ protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
+}
diff --git a/Maui/VirtualizingRecyclingScrollView/Platforms/Android/Resources/values/colors.xml b/Maui/VirtualizingRecyclingScrollView/Platforms/Android/Resources/values/colors.xml
new file mode 100644
index 0000000..5cd1604
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/Platforms/Android/Resources/values/colors.xml
@@ -0,0 +1,6 @@
+
+
+ #512BD4
+ #2B0B98
+ #2B0B98
+
\ No newline at end of file
diff --git a/Maui/VirtualizingRecyclingScrollView/Platforms/MacCatalyst/AppDelegate.cs b/Maui/VirtualizingRecyclingScrollView/Platforms/MacCatalyst/AppDelegate.cs
new file mode 100644
index 0000000..70d4e99
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/Platforms/MacCatalyst/AppDelegate.cs
@@ -0,0 +1,9 @@
+using Foundation;
+
+namespace VirtualizingRecyclingScrollView;
+
+[Register("AppDelegate")]
+public class AppDelegate : MauiUIApplicationDelegate
+{
+ protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
+}
diff --git a/Maui/VirtualizingRecyclingScrollView/Platforms/MacCatalyst/Entitlements.plist b/Maui/VirtualizingRecyclingScrollView/Platforms/MacCatalyst/Entitlements.plist
new file mode 100644
index 0000000..8e87c0c
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/Platforms/MacCatalyst/Entitlements.plist
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+ com.apple.security.app-sandbox
+
+
+ com.apple.security.network.client
+
+
+
+
diff --git a/Maui/VirtualizingRecyclingScrollView/Platforms/MacCatalyst/Info.plist b/Maui/VirtualizingRecyclingScrollView/Platforms/MacCatalyst/Info.plist
new file mode 100644
index 0000000..f24aacc
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/Platforms/MacCatalyst/Info.plist
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ UIDeviceFamily
+
+ 2
+
+ UIRequiredDeviceCapabilities
+
+ arm64
+
+ UISupportedInterfaceOrientations
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+ UISupportedInterfaceOrientations~ipad
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationPortraitUpsideDown
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+ XSAppIconAssets
+ Assets.xcassets/appicon.appiconset
+
+
diff --git a/Maui/VirtualizingRecyclingScrollView/Platforms/MacCatalyst/Program.cs b/Maui/VirtualizingRecyclingScrollView/Platforms/MacCatalyst/Program.cs
new file mode 100644
index 0000000..061bbad
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/Platforms/MacCatalyst/Program.cs
@@ -0,0 +1,15 @@
+using ObjCRuntime;
+using UIKit;
+
+namespace VirtualizingRecyclingScrollView;
+
+public class Program
+{
+ // This is the main entry point of the application.
+ static void Main(string[] args)
+ {
+ // if you want to use a different Application Delegate class from "AppDelegate"
+ // you can specify it here.
+ UIApplication.Main(args, null, typeof(AppDelegate));
+ }
+}
diff --git a/Maui/VirtualizingRecyclingScrollView/Platforms/Tizen/Main.cs b/Maui/VirtualizingRecyclingScrollView/Platforms/Tizen/Main.cs
new file mode 100644
index 0000000..663d772
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/Platforms/Tizen/Main.cs
@@ -0,0 +1,16 @@
+using System;
+using Microsoft.Maui;
+using Microsoft.Maui.Hosting;
+
+namespace VirtualizingRecyclingScrollView;
+
+class Program : MauiApplication
+{
+ protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
+
+ static void Main(string[] args)
+ {
+ var app = new Program();
+ app.Run(args);
+ }
+}
diff --git a/Maui/VirtualizingRecyclingScrollView/Platforms/Tizen/tizen-manifest.xml b/Maui/VirtualizingRecyclingScrollView/Platforms/Tizen/tizen-manifest.xml
new file mode 100644
index 0000000..9d8013a
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/Platforms/Tizen/tizen-manifest.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+ maui-appicon-placeholder
+
+
+
+
+ http://tizen.org/privilege/internet
+
+
+
+
\ No newline at end of file
diff --git a/Maui/VirtualizingRecyclingScrollView/Platforms/Windows/App.xaml b/Maui/VirtualizingRecyclingScrollView/Platforms/Windows/App.xaml
new file mode 100644
index 0000000..5868c22
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/Platforms/Windows/App.xaml
@@ -0,0 +1,8 @@
+
+
+
diff --git a/Maui/VirtualizingRecyclingScrollView/Platforms/Windows/App.xaml.cs b/Maui/VirtualizingRecyclingScrollView/Platforms/Windows/App.xaml.cs
new file mode 100644
index 0000000..3f908e9
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/Platforms/Windows/App.xaml.cs
@@ -0,0 +1,24 @@
+using Microsoft.UI.Xaml;
+
+// To learn more about WinUI, the WinUI project structure,
+// and more about our project templates, see: http://aka.ms/winui-project-info.
+
+namespace VirtualizingRecyclingScrollView.WinUI;
+
+///
+/// Provides application-specific behavior to supplement the default Application class.
+///
+public partial class App : MauiWinUIApplication
+{
+ ///
+ /// Initializes the singleton application object. This is the first line of authored code
+ /// executed, and as such is the logical equivalent of main() or WinMain().
+ ///
+ public App()
+ {
+ this.InitializeComponent();
+ }
+
+ protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
+}
+
diff --git a/Maui/VirtualizingRecyclingScrollView/Platforms/Windows/Package.appxmanifest b/Maui/VirtualizingRecyclingScrollView/Platforms/Windows/Package.appxmanifest
new file mode 100644
index 0000000..a00d837
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/Platforms/Windows/Package.appxmanifest
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+ $placeholder$
+ User Name
+ $placeholder$.png
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Maui/VirtualizingRecyclingScrollView/Platforms/Windows/app.manifest b/Maui/VirtualizingRecyclingScrollView/Platforms/Windows/app.manifest
new file mode 100644
index 0000000..429d105
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/Platforms/Windows/app.manifest
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+ true/PM
+ PerMonitorV2, PerMonitor
+
+
+
diff --git a/Maui/VirtualizingRecyclingScrollView/Platforms/iOS/AppDelegate.cs b/Maui/VirtualizingRecyclingScrollView/Platforms/iOS/AppDelegate.cs
new file mode 100644
index 0000000..75b6e02
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/Platforms/iOS/AppDelegate.cs
@@ -0,0 +1,11 @@
+using Foundation;
+using ObjCRuntime;
+using UIKit;
+
+namespace VirtualizingRecyclingScrollView;
+
+[Register("AppDelegate")]
+public class AppDelegate : MauiUIApplicationDelegate
+{
+ protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
+}
diff --git a/Maui/VirtualizingRecyclingScrollView/Platforms/iOS/Info.plist b/Maui/VirtualizingRecyclingScrollView/Platforms/iOS/Info.plist
new file mode 100644
index 0000000..358337b
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/Platforms/iOS/Info.plist
@@ -0,0 +1,32 @@
+
+
+
+
+ LSRequiresIPhoneOS
+
+ UIDeviceFamily
+
+ 1
+ 2
+
+ UIRequiredDeviceCapabilities
+
+ arm64
+
+ UISupportedInterfaceOrientations
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+ UISupportedInterfaceOrientations~ipad
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationPortraitUpsideDown
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+ XSAppIconAssets
+ Assets.xcassets/appicon.appiconset
+
+
diff --git a/Maui/VirtualizingRecyclingScrollView/Platforms/iOS/Program.cs b/Maui/VirtualizingRecyclingScrollView/Platforms/iOS/Program.cs
new file mode 100644
index 0000000..061bbad
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/Platforms/iOS/Program.cs
@@ -0,0 +1,15 @@
+using ObjCRuntime;
+using UIKit;
+
+namespace VirtualizingRecyclingScrollView;
+
+public class Program
+{
+ // This is the main entry point of the application.
+ static void Main(string[] args)
+ {
+ // if you want to use a different Application Delegate class from "AppDelegate"
+ // you can specify it here.
+ UIApplication.Main(args, null, typeof(AppDelegate));
+ }
+}
diff --git a/Maui/VirtualizingRecyclingScrollView/Platforms/iOS/Resources/PrivacyInfo.xcprivacy b/Maui/VirtualizingRecyclingScrollView/Platforms/iOS/Resources/PrivacyInfo.xcprivacy
new file mode 100644
index 0000000..1ea3a5d
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/Platforms/iOS/Resources/PrivacyInfo.xcprivacy
@@ -0,0 +1,51 @@
+
+
+
+
+
+ NSPrivacyAccessedAPITypes
+
+
+ NSPrivacyAccessedAPIType
+ NSPrivacyAccessedAPICategoryFileTimestamp
+ NSPrivacyAccessedAPITypeReasons
+
+ C617.1
+
+
+
+ NSPrivacyAccessedAPIType
+ NSPrivacyAccessedAPICategorySystemBootTime
+ NSPrivacyAccessedAPITypeReasons
+
+ 35F9.1
+
+
+
+ NSPrivacyAccessedAPIType
+ NSPrivacyAccessedAPICategoryDiskSpace
+ NSPrivacyAccessedAPITypeReasons
+
+ E174.1
+
+
+
+
+
+
diff --git a/Maui/VirtualizingRecyclingScrollView/Properties/launchSettings.json b/Maui/VirtualizingRecyclingScrollView/Properties/launchSettings.json
new file mode 100644
index 0000000..f4c6c8d
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/Properties/launchSettings.json
@@ -0,0 +1,8 @@
+{
+ "profiles": {
+ "Windows Machine": {
+ "commandName": "Project",
+ "nativeDebugging": false
+ }
+ }
+}
\ No newline at end of file
diff --git a/Maui/VirtualizingRecyclingScrollView/README.md b/Maui/VirtualizingRecyclingScrollView/README.md
new file mode 100644
index 0000000..54643ad
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/README.md
@@ -0,0 +1,12 @@
+# Virtualized Recycling ScrollView
+The bread and butter of a virtualized recycling scrollview in about 300 lines of code:
+https://github.com/telerik/ms-samples/pull/80
+
+It steps on the ideas of this:
+https://wwdcnotes.com/documentation/wwdcnotes/wwdc11-104-advanced-scrollview-techniques/
+
+The scrollview will update the children within its content using a custom layout, it involves arranging items that disappear from the top to move them to the bottom also updating their content.
+
+There are two number fields at the titlebar:
+ - the left one shows measure and arrange counts for views outside the scrollview
+ - the right one shows measure and arrange counts for views in the scrollview
diff --git a/Maui/VirtualizingRecyclingScrollView/Resources/AppIcon/appicon.svg b/Maui/VirtualizingRecyclingScrollView/Resources/AppIcon/appicon.svg
new file mode 100644
index 0000000..5f04fcf
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/Resources/AppIcon/appicon.svg
@@ -0,0 +1,4 @@
+
+
\ No newline at end of file
diff --git a/Maui/VirtualizingRecyclingScrollView/Resources/AppIcon/appiconfg.svg b/Maui/VirtualizingRecyclingScrollView/Resources/AppIcon/appiconfg.svg
new file mode 100644
index 0000000..62d66d7
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/Resources/AppIcon/appiconfg.svg
@@ -0,0 +1,8 @@
+
+
+
\ No newline at end of file
diff --git a/Maui/VirtualizingRecyclingScrollView/Resources/Fonts/OpenSans-Regular.ttf b/Maui/VirtualizingRecyclingScrollView/Resources/Fonts/OpenSans-Regular.ttf
new file mode 100644
index 0000000..1289e1b
Binary files /dev/null and b/Maui/VirtualizingRecyclingScrollView/Resources/Fonts/OpenSans-Regular.ttf differ
diff --git a/Maui/VirtualizingRecyclingScrollView/Resources/Fonts/OpenSans-Semibold.ttf b/Maui/VirtualizingRecyclingScrollView/Resources/Fonts/OpenSans-Semibold.ttf
new file mode 100644
index 0000000..39f2c49
Binary files /dev/null and b/Maui/VirtualizingRecyclingScrollView/Resources/Fonts/OpenSans-Semibold.ttf differ
diff --git a/Maui/VirtualizingRecyclingScrollView/Resources/Images/dotnet_bot.png b/Maui/VirtualizingRecyclingScrollView/Resources/Images/dotnet_bot.png
new file mode 100644
index 0000000..f93ce02
Binary files /dev/null and b/Maui/VirtualizingRecyclingScrollView/Resources/Images/dotnet_bot.png differ
diff --git a/Maui/VirtualizingRecyclingScrollView/Resources/Raw/AboutAssets.txt b/Maui/VirtualizingRecyclingScrollView/Resources/Raw/AboutAssets.txt
new file mode 100644
index 0000000..f22d3bf
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/Resources/Raw/AboutAssets.txt
@@ -0,0 +1,15 @@
+Any raw assets you want to be deployed with your application can be placed in
+this directory (and child directories). Deployment of the asset to your application
+is automatically handled by the following `MauiAsset` Build Action within your `.csproj`.
+
+
+
+These files will be deployed with your package and will be accessible using Essentials:
+
+ async Task LoadMauiAsset()
+ {
+ using var stream = await FileSystem.OpenAppPackageFileAsync("AboutAssets.txt");
+ using var reader = new StreamReader(stream);
+
+ var contents = reader.ReadToEnd();
+ }
diff --git a/Maui/VirtualizingRecyclingScrollView/Resources/Splash/splash.svg b/Maui/VirtualizingRecyclingScrollView/Resources/Splash/splash.svg
new file mode 100644
index 0000000..62d66d7
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/Resources/Splash/splash.svg
@@ -0,0 +1,8 @@
+
+
+
\ No newline at end of file
diff --git a/Maui/VirtualizingRecyclingScrollView/Resources/Styles/Colors.xaml b/Maui/VirtualizingRecyclingScrollView/Resources/Styles/Colors.xaml
new file mode 100644
index 0000000..22f0a67
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/Resources/Styles/Colors.xaml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+ #512BD4
+ #ac99ea
+ #242424
+ #DFD8F7
+ #9880e5
+ #2B0B98
+
+ White
+ Black
+ #D600AA
+ #190649
+ #1f1f1f
+
+ #E1E1E1
+ #C8C8C8
+ #ACACAC
+ #919191
+ #6E6E6E
+ #404040
+ #212121
+ #141414
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Maui/VirtualizingRecyclingScrollView/Resources/Styles/Styles.xaml b/Maui/VirtualizingRecyclingScrollView/Resources/Styles/Styles.xaml
new file mode 100644
index 0000000..628f887
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/Resources/Styles/Styles.xaml
@@ -0,0 +1,451 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Maui/VirtualizingRecyclingScrollView/TheScrollView.cs b/Maui/VirtualizingRecyclingScrollView/TheScrollView.cs
new file mode 100644
index 0000000..5ce1049
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/TheScrollView.cs
@@ -0,0 +1,211 @@
+using System.Diagnostics.CodeAnalysis;
+using Microsoft.Maui.Layouts;
+
+namespace VirtualizingRecyclingScrollView;
+
+public class TheScrollView : ScrollView
+{
+ public DataTemplate Template { get; set; }
+
+ const double RowHeight = 50;
+ const double ColumnWidth = 140;
+
+ private Point scroll;
+ private Size size;
+ private Rect rect;
+
+ private Container container;
+
+ public TheScrollView()
+ {
+ this.container = new Container(this);
+ this.Content = container;
+ this.Scrolled += OnScrolled;
+ this.Orientation = ScrollOrientation.Both;
+ }
+
+ private void OnScrolled(object? sender, ScrolledEventArgs args)
+ {
+ DateTime start = DateTime.Now;
+ this.scroll = new Point(this.ScrollX, this.ScrollY);
+ this.rect = new Rect(this.scroll.X, this.scroll.Y, this.size.Width, this.size.Height);
+ var change = this.container.layoutManager.RealizeViewport();
+ if (change != 0)
+ {
+ Console.WriteLine($" = OnScrolled {DateTime.Now - start}");
+ }
+ }
+
+ protected override void OnHandlerChanged()
+ {
+ base.OnHandlerChanged();
+#if IOS
+ var scrollview = (UIKit.UIScrollView)this.Handler.PlatformView;
+ scrollview.ContentInset = new UIKit.UIEdgeInsets(60, 0, 50, 0);
+ scrollview.VerticalScrollIndicatorInsets = new UIKit.UIEdgeInsets(50, 0, 20, 0);
+ scrollview.HorizontalScrollIndicatorInsets = new UIKit.UIEdgeInsets(0, 0, 20, 0);
+#endif
+ }
+
+ protected override Size ArrangeOverride(Rect bounds)
+ {
+ Console.WriteLine(" - ScrollView Arrange");
+ DateTime start = DateTime.Now;
+ this.size = base.ArrangeOverride(bounds);
+ this.rect = new Rect(this.scroll.X, this.scroll.Y, this.size.Width, this.size.Height);
+ Console.WriteLine($" ScrollView Arranged {DateTime.Now - start}");
+ return this.size;
+ }
+
+ protected override Size MeasureOverride(double widthConstraint, double heightConstraint)
+ {
+ Console.WriteLine(" - ScrollView Measure");
+ DateTime start = DateTime.Now;
+ TrackingModel.Instance.LayoutNodes++;
+ this.size = base.MeasureOverride(widthConstraint, heightConstraint);
+ this.rect = new Rect(this.scroll.X, this.scroll.Y, this.size.Width, this.size.Height);
+ Console.WriteLine($" ScrollView Measured {DateTime.Now - start}");
+ return size;
+ }
+
+ private class Container : Layout
+ {
+ public TheScrollView scrollview;
+ public LayoutManager layoutManager;
+
+ public Container(TheScrollView scrollview)
+ {
+ this.scrollview = scrollview;
+ this.layoutManager = new LayoutManager(this);
+ }
+
+ protected override ILayoutManager CreateLayoutManager()
+ {
+ return this.layoutManager;
+ }
+ }
+
+ private class LayoutManager : ILayoutManager, IEqualityComparer
+ {
+ private Container container;
+
+ private Dictionary elements = new Dictionary();
+
+ private Stack trashbin = new Stack();
+
+ private Stack disappearingViews = new Stack();
+
+ private int currentLeft = -1;
+ private int currentRight = -1;
+ private int currentTop = -1;
+ private int currentBottom = -1;
+
+ public LayoutManager(Container container)
+ {
+ this.container = container;
+ }
+
+ public bool Equals(Key lhs, Key rhs) => lhs.x == rhs.x && lhs.y == rhs.y;
+
+ public int GetHashCode([DisallowNull] Key obj) => obj.x * 67033 + obj.y * 67043;
+
+ public Size ArrangeChildren(Rect bounds)
+ {
+ return new Size(10000, 10000);
+ }
+
+ public Size Measure(double widthConstraint, double heightConstraint)
+ {
+ return new Size(10000, 10000);
+ }
+
+ public int RealizeViewport()
+ {
+ int left = Math.Max(0, (int)Math.Floor(this.container.scrollview.rect.X / ColumnWidth));
+ int right = (int)Math.Ceiling((this.container.scrollview.rect.X + this.container.scrollview.rect.Width) / ColumnWidth);
+ int top = Math.Max(0, (int)Math.Floor(this.container.scrollview.rect.Y / RowHeight));
+ int bottom = (int)Math.Ceiling((this.container.scrollview.rect.Y + this.container.scrollview.Height) / RowHeight);
+
+ if (left == currentLeft && top != currentTop && right != currentRight && bottom != currentBottom)
+ {
+ return 0;
+ }
+
+ this.currentLeft = left;
+ this.currentRight = right;
+ this.currentTop = top;
+ this.currentBottom = bottom;
+
+ int removed = 0;
+ int added = 0;
+
+ foreach(var kvp in this.elements)
+ {
+ if (kvp.Key.x < left || kvp.Key.x > right || kvp.Key.y < top || kvp.Key.y > bottom)
+ {
+ this.disappearingViews.Push(kvp.Value);
+ this.elements.Remove(kvp.Key);
+ removed++;
+ }
+ }
+
+ for (int x = left; x <= right; x++)
+ {
+ for (int y = top; y <= bottom; y++)
+ {
+ var key = new Key(x, y);
+ if (!elements.ContainsKey(key))
+ {
+ View? content = null;
+ if (this.disappearingViews.Count > 0)
+ {
+ content = this.disappearingViews.Pop();
+ }
+ else if (this.trashbin.Count > 0)
+ {
+ content = this.trashbin.Pop();
+ }
+ else
+ {
+ content = this.container.scrollview.Template.CreateContent() as View;
+ content.BindingContext = new CellModel();
+ this.container.Add(content);
+ }
+
+ content.IsVisible = true;
+ var cellmodel = (CellModel)content.BindingContext;
+ cellmodel.key = key;
+ var code = this.container.layoutManager.GetHashCode(key);
+ cellmodel.Color = new Color(200 + code % 56, 200 + (code >> 4) % 56, 200 + (byte)(code >> 8) % 56);
+ cellmodel.Text = $"Cell {x} x {y}";
+ elements[key] = content;
+
+ // We measure and arrange ad-hoc
+#if IOS
+ content.Arrange(new Rect(cellmodel.key.x * ColumnWidth, cellmodel.key.y * RowHeight, ColumnWidth, RowHeight));
+#else
+ content.Measure(double.PositiveInfinity, double.PositiveInfinity);
+ content.Arrange(new Rect(cellmodel.key.x * ColumnWidth, cellmodel.key.y * RowHeight, ColumnWidth, RowHeight));
+#endif
+
+ added++;
+ }
+ }
+ }
+
+ while(this.disappearingViews.Count > 0)
+ {
+ var popped = this.disappearingViews.Pop();
+ popped.IsVisible = false;
+ this.trashbin.Push(popped);
+ }
+
+ if (removed != 0 || added != 0)
+ {
+ Console.WriteLine($" +{added}/-{removed}");
+ }
+
+ return added + removed;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Maui/VirtualizingRecyclingScrollView/TrackingBorder.cs b/Maui/VirtualizingRecyclingScrollView/TrackingBorder.cs
new file mode 100644
index 0000000..9e3feb1
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/TrackingBorder.cs
@@ -0,0 +1,35 @@
+
+namespace VirtualizingRecyclingScrollView;
+
+public class TrackingBorder : Border
+{
+ public bool Virtualized { get; set; } = false;
+
+ protected override Size ArrangeOverride(Rect bounds)
+ {
+ if (this.Virtualized)
+ {
+ TrackingModel.Instance.LayoutVirtualNodes++;
+ }
+ else
+ {
+ TrackingModel.Instance.LayoutNodes++;
+ }
+
+ return base.ArrangeOverride(bounds);
+ }
+
+ protected override Size MeasureOverride(double widthConstraint, double heightConstraint)
+ {
+ if (this.Virtualized)
+ {
+ TrackingModel.Instance.LayoutVirtualNodes++;
+ }
+ else
+ {
+ TrackingModel.Instance.LayoutNodes++;
+ }
+
+ return base.MeasureOverride(widthConstraint, heightConstraint);
+ }
+}
\ No newline at end of file
diff --git a/Maui/VirtualizingRecyclingScrollView/TrackingLabel.cs b/Maui/VirtualizingRecyclingScrollView/TrackingLabel.cs
new file mode 100644
index 0000000..95026bc
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/TrackingLabel.cs
@@ -0,0 +1,34 @@
+namespace VirtualizingRecyclingScrollView;
+
+public class TrackingLabel : Label
+{
+ public bool Virtualized { get; set; } = false;
+
+ protected override Size ArrangeOverride(Rect bounds)
+ {
+ if (this.Virtualized)
+ {
+ TrackingModel.Instance.LayoutVirtualNodes++;
+ }
+ else
+ {
+ TrackingModel.Instance.LayoutNodes++;
+ }
+
+ return base.ArrangeOverride(bounds);
+ }
+
+ protected override Size MeasureOverride(double widthConstraint, double heightConstraint)
+ {
+ if (this.Virtualized)
+ {
+ TrackingModel.Instance.LayoutVirtualNodes++;
+ }
+ else
+ {
+ TrackingModel.Instance.LayoutNodes++;
+ }
+
+ return base.MeasureOverride(widthConstraint, heightConstraint);
+ }
+}
\ No newline at end of file
diff --git a/Maui/VirtualizingRecyclingScrollView/TrackingModel.cs b/Maui/VirtualizingRecyclingScrollView/TrackingModel.cs
new file mode 100644
index 0000000..c5b486d
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/TrackingModel.cs
@@ -0,0 +1,38 @@
+using System.ComponentModel;
+
+namespace VirtualizingRecyclingScrollView;
+
+public sealed class TrackingModel : INotifyPropertyChanged
+{
+ public static TrackingModel Instance = new TrackingModel();
+
+ private TrackingModel()
+ {
+ }
+
+ private uint layoutNodes = 0;
+
+ private uint layoutVirtualNodes = 0;
+
+ public event PropertyChangedEventHandler? PropertyChanged;
+
+ public uint LayoutNodes
+ {
+ get => this.layoutNodes;
+ set
+ {
+ this.layoutNodes = value;
+ this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(LayoutNodes)));
+ }
+ }
+
+ public uint LayoutVirtualNodes
+ {
+ get => this.layoutVirtualNodes;
+ set
+ {
+ this.layoutVirtualNodes = value;
+ this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(LayoutVirtualNodes)));
+ }
+ }
+}
diff --git a/Maui/VirtualizingRecyclingScrollView/VirtualizingRecyclingScrollView.csproj b/Maui/VirtualizingRecyclingScrollView/VirtualizingRecyclingScrollView.csproj
new file mode 100644
index 0000000..b50d36a
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/VirtualizingRecyclingScrollView.csproj
@@ -0,0 +1,68 @@
+
+
+
+ net9.0-android;net9.0-ios;net9.0-maccatalyst
+ $(TargetFrameworks);net9.0-windows10.0.19041.0
+
+
+
+
+
+
+ Exe
+ VirtualizingRecyclingScrollView
+ true
+ true
+ enable
+ enable
+
+
+ VirtualizingRecyclingScrollView
+
+
+ com.companyname.virtualizingrecyclingscrollview
+
+
+ 1.0
+ 1
+
+
+ None
+
+ 15.0
+ 15.0
+ 21.0
+ 10.0.17763.0
+ 10.0.17763.0
+ 6.5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Maui/VirtualizingRecyclingScrollView/VirtualizingRecyclingScrollView.sln b/Maui/VirtualizingRecyclingScrollView/VirtualizingRecyclingScrollView.sln
new file mode 100644
index 0000000..bce68f4
--- /dev/null
+++ b/Maui/VirtualizingRecyclingScrollView/VirtualizingRecyclingScrollView.sln
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.0.31903.59
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VirtualizingRecyclingScrollView", "VirtualizingRecyclingScrollView.csproj", "{FBCA23F3-6748-49A3-B8DC-05B619B2B1A5}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {FBCA23F3-6748-49A3-B8DC-05B619B2B1A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FBCA23F3-6748-49A3-B8DC-05B619B2B1A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FBCA23F3-6748-49A3-B8DC-05B619B2B1A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FBCA23F3-6748-49A3-B8DC-05B619B2B1A5}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+EndGlobal