Previous part: Listing Information from the Local DB in MAUI .NET 9 [GamesCatalog] - Part 15
Step 1. Let’s create a function to remove a game from the list. In GameRepo, we’ll add a function to inactivate the game and declare it in the interface.
Step 1.1. Let’s modify the UpdateStatusAsync so that if the game exists in the local database and is inactive, it is reactivated.
![UpdateStatusAsync]()
Code of UpdateStatusAsync
Step 2. In GameService, we’ll add the InactivateAsync function and declare it in the interface.
Step 3. In GameList.xaml, we’ll set a tap on an item in the list to navigate to the game addition screen.
![GameList.xaml]()
Add the command and use [Ctrl + space] to add the function.
Step 3.1. In GameList.xaml.cs, the function will open the game addition screen, passing the game object from the list.
Step 4. In AddGameVM.cs, we’ll add a variable to control the visibility of the Expander, which will contain the option to remove a game:
Step 4.1. In the BuildGameStatus function, we’ll set ExpanderIsVisible to true when the game exists in the local database and is not inactive.
![BuildGameStatus function]()
Code of BuildGameStatus
Step 4.2. And we’ll create a command to inactivate the game, removing it from our list:
Step 5. In AddGame.xaml, let’s add the toolkit usage:
![AddGame.xaml]()
Code
Step 5.1. And we’ll create an Expander, which will currently only contain the option to remove the game from the list:
![Expander]()
Code for the Expander
Step 6. Let’s add styles for the buttons inside the Expander:
![Add styles for the buttons]()
Code
Step 7. In GameListVM.cs, we’ll clear the list when the screen is opened.
![GameListVM.cs]()
Code for ApplyQueryAttributes
Step 8. With this, we have the option to remove a game from the list.
![Option of removing a game]()
Initial state of the Expander.
![Initial state of the Expander]()
On tap, it reveals the removal option. If the game is removed, we return to the updated game list.
Step 9. Since we return to the game list, let’s add a search function to this page. For this, we’ll add a variable in GameListVM.cs that will be bound to the search field:
Step 10. Then, let’s add a function that performs the search if the search text hasn’t changed for a second and a half:
If any text is entered within that second and a half window, the task is canceled before the search begins.
Step 10.1. We’ll pass the search text to the service:
![Service]()
Code for LoadGames() and declaration of searchSemaphore:
Step 10.2. In the service, we’ll modify the GetByStatusAsync function to conditionally call the function that performs a text-based search in the local database.
![GetByStatusAsync function]()
Code for GetByStatusAsync
![Reference]()
Update the interface with the new field.
Step 10.3. In GameRepo.cs, let’s add the function that performs the text search and declare it in the interface:
Step 11. Now our search works on the screen:
![Search works on screen]()
![Goddwar]()
Selecting a game from the list takes us to the game details screen. There, we can select and confirm the option to remove the game from the list.
![Playing]()
Removing the searched game from the list returns us to the screen with the game no longer appearing in the results.
Next part: Setting the App Icon and SplashScreen in MAUI [GamesCatalog] 17
Code on git: GamesCatalog