fix: replace deprecated ListView with CollectionView in TodoApp.MAUI#566
Merged
Conversation
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 CommunityToolkit#515
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the deprecated
Microsoft.Maui.Controls.ListViewwithCollectionViewin theTodoApp.MAUIsample'sMainPage, eliminating theCS0618obsolete-API warning surfaced by the new Windows CI (#514):Changes
MainPage.xaml: replaced<ListView>/<ListView.ItemTemplate>with<CollectionView>/<CollectionView.ItemTemplate>, removing the<ViewCell>wrapper (not used byCollectionViewitem templates — theDataTemplatecontent is now the direct visual). AddedSelectionMode="Single"and swappedItemTapped="OnListItemTapped"forSelectionChanged="OnListItemTapped".MainPage.xaml.cs: updatedOnListItemTappedto acceptSelectionChangedEventArgs, reading the tapped item viae.CurrentSelection.FirstOrDefault()instead ofe.Item, and castsendertoCollectionView(instead ofListView) to resetSelectedItem = nullafter handling the tap — preserving the existing "tap to act, then deselect" behavior.Resources/Styles/Styles.xaml: removed the now-unused implicit<Style TargetType="ListView">(SeparatorColor/RefreshControlColor), sinceListViewis no longer used anywhere in this project andCollectionViewdoesn't have equivalent properties.Testing
dotnet build/dotnet testagainst the main solution (unaffected, since these are sample-only changes not included inDatasync.Toolkit.sln).Build SamplesCI workflow (workflow_dispatchonissues/515): all sample jobs passed, includingtodoapp-maui(Android/iOS) andtodoapp-windows(which builds the MAUI Windows TFM head — the job that originally surfaced this warning). Confirmed0 Warning(s)in the MAUI Windows build step logs, versus the previousCS0618warning.Closes #515