From f9fb282302fbca00596d3c2fef3a9ec87730ca6a Mon Sep 17 00:00:00 2001 From: ahall Date: Sat, 11 Jul 2026 10:44:02 +0100 Subject: [PATCH] fix: replace deprecated ListView with CollectionView in TodoApp.MAUI Replaces the obsolete Microsoft.Maui.Controls.ListView (CS0618) with CollectionView in the TodoApp.MAUI sample's MainPage, removing the ViewCell wrapper the new control doesn't use and switching the tap handler from ItemTapped/ItemTappedEventArgs to SelectionChanged/SelectionChangedEventArgs (SelectionMode=Single, resetting SelectedItem afterward to preserve tap-then-deselect behavior). Also removes the now-unused implicit ListView style from Styles.xaml. Closes #515 --- samples/todoapp/TodoApp.MAUI/MainPage.xaml | 41 ++++++++++--------- samples/todoapp/TodoApp.MAUI/MainPage.xaml.cs | 6 +-- .../TodoApp.MAUI/Resources/Styles/Styles.xaml | 5 --- 3 files changed, 24 insertions(+), 28 deletions(-) diff --git a/samples/todoapp/TodoApp.MAUI/MainPage.xaml b/samples/todoapp/TodoApp.MAUI/MainPage.xaml index b06b9c36..5d896b7f 100644 --- a/samples/todoapp/TodoApp.MAUI/MainPage.xaml +++ b/samples/todoapp/TodoApp.MAUI/MainPage.xaml @@ -21,29 +21,30 @@ - - + + - - - - - - - - - + + + + + + + + - - + - - + + diff --git a/samples/todoapp/TodoApp.MAUI/MainPage.xaml.cs b/samples/todoapp/TodoApp.MAUI/MainPage.xaml.cs index ab1cde80..857617ef 100644 --- a/samples/todoapp/TodoApp.MAUI/MainPage.xaml.cs +++ b/samples/todoapp/TodoApp.MAUI/MainPage.xaml.cs @@ -24,14 +24,14 @@ protected override void OnAppearing() this._viewModel.RefreshItemsCommand.Execute(null); } - public void OnListItemTapped(object sender, ItemTappedEventArgs e) + public void OnListItemTapped(object sender, SelectionChangedEventArgs e) { - if (e.Item is TodoItem item) + if (e.CurrentSelection.FirstOrDefault() is TodoItem item) { this._viewModel.UpdateItemCommand.Execute(item.Id); } - if (sender is ListView itemList) + if (sender is CollectionView itemList) { itemList.SelectedItem = null; } diff --git a/samples/todoapp/TodoApp.MAUI/Resources/Styles/Styles.xaml b/samples/todoapp/TodoApp.MAUI/Resources/Styles/Styles.xaml index cd05dbfc..57da6f1a 100644 --- a/samples/todoapp/TodoApp.MAUI/Resources/Styles/Styles.xaml +++ b/samples/todoapp/TodoApp.MAUI/Resources/Styles/Styles.xaml @@ -278,11 +278,6 @@ - -