Skip to content

Conversation

Vignesh-SF3580
Copy link
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Description of Change

Updated the maui-mobile developer sample with the latest changes from maui-sample.
After changing ScrollView to CollectionView, a null exception occurred when clicking on projects. I resolved this issue using Javier's changes.

Associated Pull Requests

dotnet/maui-samples#662

Screenshots

Before Issue Fix After Issue Fix
image image

Copy link
Contributor

Hey there @@Vignesh-SF3580! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels Sep 17, 2025
@Tamilarasan-Paranthaman Tamilarasan-Paranthaman added the area-templates Project templates, Item Templates for Blazor and MAUI label Sep 17, 2025
@Vignesh-SF3580 Vignesh-SF3580 marked this pull request as ready for review September 17, 2025 13:31
@Copilot Copilot AI review requested due to automatic review settings September 17, 2025 13:31
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the maui-mobile developer sample by updating the UI layout and fixing a null reference exception that occurred when clicking on projects after switching from ScrollView to CollectionView.

  • Replaces VerticalStackLayout with Grid layout for better organization
  • Switches from HorizontalStackLayout with BindableLayout to CollectionView for project display
  • Adds null checking in the NavigateToProject command to prevent exceptions

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/Templates/src/templates/maui-mobile/Pages/MainPage.xaml Refactors layout from VerticalStackLayout to Grid and replaces project display with CollectionView
src/Templates/src/templates/maui-mobile/PageModels/MainPageModel.cs Adds SelectedProject property and null checking in NavigateToProject command

Comment on lines +155 to +156
private Task? NavigateToProject(Project project)
=> project is null ? null : Shell.Current.GoToAsync($"project?id={project.ID}");
Copy link
Preview

Copilot AI Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method returns Task? which creates an inconsistent API design. Consider throwing ArgumentNullException for null projects or restructuring to always return a completed Task to maintain a consistent return type.

Copilot uses AI. Check for mistakes.

Comment on lines +60 to +61
SelectionChangedCommand="{Binding NavigateToProjectCommand, Source={RelativeSource AncestorType={x:Type pageModels:MainPageModel}}, x:DataType=pageModels:MainPageModel}"
SelectionChangedCommandParameter="{Binding SelectedProject}">
Copy link
Preview

Copilot AI Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SelectionChangedCommandParameter binding to SelectedProject is redundant since the SelectedItem is already bound to SelectedProject. The command can access the selected project directly through the SelectedProject property, eliminating the need for the command parameter.

Suggested change
SelectionChangedCommand="{Binding NavigateToProjectCommand, Source={RelativeSource AncestorType={x:Type pageModels:MainPageModel}}, x:DataType=pageModels:MainPageModel}"
SelectionChangedCommandParameter="{Binding SelectedProject}">
SelectionChangedCommand="{Binding NavigateToProjectCommand, Source={RelativeSource AncestorType={x:Type pageModels:MainPageModel}}, x:DataType=pageModels:MainPageModel}">

Copilot uses AI. Check for mistakes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, can simplify it because the command can access the selected project directly through the SelectedProject property. I'm ok with both options.

@sheiksyedm sheiksyedm requested a review from Copilot September 17, 2025 15:07
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment on lines +155 to +156
private Task? NavigateToProject(Project project)
=> project is null ? null : Shell.Current.GoToAsync($"project?id={project.ID}");
Copy link
Preview

Copilot AI Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method should return a consistent Task type rather than nullable Task. Consider returning Task.CompletedTask for null projects instead of null to maintain a consistent async pattern.

Suggested change
private Task? NavigateToProject(Project project)
=> project is null ? null : Shell.Current.GoToAsync($"project?id={project.ID}");
private Task NavigateToProject(Project project)
=> project is null ? Task.CompletedTask : Shell.Current.GoToAsync($"project?id={project.ID}");

Copilot uses AI. Check for mistakes.

@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-templates Project templates, Item Templates for Blazor and MAUI community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants