Analyzing the Xamarin CRM app with XamRight

The Xamarin CRM demo app is meant to display best practices and how to effectively use some features in using Xamarin Forms in the context of a complete app.

We cloned the repo and ran XamRight on the source code (without any modifications) to see what we could find and to demo some XamRight features.  The CRM app has five warnings detected by XamRight, listed below (we disabled some inefficient layout warning detection for this exercise). None of these are catastrophic, but should be resolved to demonstrate truly clean, maintainable code.  Keep reading to get to a quick video showing how XamRight helps find and fix XAML bugs and navigate around your Xamarin Forms source code.

For example, the XR5038 warning about mistakes in declaring a grouped ListView, is fairly common in our experience.  Having a truly clean example of proper use of a grouped  LIstView would be helpful; otherwise people will take the code and be confused because they don’t realize that a single ListView won’t display both GroupHeaderTemplate and GroupDisplayBinding.

Code Description File Line
XR5010 Binding for ‘Title’ is to a property that doesn’t exist in possible BindingContext type ‘OrdersViewModel’ Pages\Customers\CustomerOrdersPage.xaml 11
XR5010 Binding for ‘Title’ is to a property that doesn’t exist in possible BindingContext type ‘CustomerSalesViewModel’ Pages\Customers\CustomerSalesPage.xaml 8
XR5033 XAML namespace declaration for ‘layouts’ references namespace ‘XamarinCRM.Layouts’ which does not exist Pages\Customers\CustomerOrdersPage.xaml 9
XR5038 ListView.GroupHeaderTemplate conflicts with GroupDisplayBinding previously declared on line 16; one of the two header definitions will be ignored Views\Customers\CustomerOrderListView.xaml 71
XR5309 Grid property ‘Grid.Row’ should only be set if view is direct child of a Grid layout Pages\MenuPage.xaml 18

Warnings like XR5039, Grid.Row has no effect unless the parent is a Grid, can be useful when refactoring a XAML file to indicate that the Grid attribute which used to do something is now ignored.

The video shows the warning in the CustomerSalesPage.xaml, and a little about using XamRight to understand and fix the warning, and to help navigate around the project.

Author

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.