Going Beyond the Basics with Xamarin.Forms
- Indy.Code() - March 30, 2017
At the heart of a great Xamarin.Forms mobile app is the ability to customize the user experience and shorten development time with reusable components. In this session, you will learn the skills to create high quality, robust, and beautiful apps all the while creating an arsenal of reusable components. You will learn how to extend Xamarin.Forms controls beyond their built-in abilities; how to style user interfaces, display dynamic data within lists and build complex layouts with grids; you’ll even learn how to integrate native controls right into the shared code layer. When you’re finished with this session, you’ll have the knowledge of Xamarin.Forms necessary to create fantastic apps in the real world.
Behaviors - in this demo we explored how behaviors added functionality to a control without having to subclass the control. Some important things to notice are how the control being acted on is passed into the
OnDetachingFromfunctions. This lets you setup event handlers on the control in question to add the additional behavior to it.
DataTemplateSelectors - these are slick! They give a
ListViewthe ability to diplay more than one cell type. The
RecipeDataTemplateSelectordoes the work for us here. Notice the 2
DataTemplatesare only being instantiated in the constructor and then held as class level variables. The
DataTemplates are initialized with the type of
ViewCellthey will display. Then within the
OnSelectTemplatefunction - the correct template is selected based off the
itemparameter. That parameter happens to be an individual item class the
ListViewis bound to.
Styles - In this demo you saw how app themeing can be achieved through the clever use of styles. Everything is occuring with the
RecommendedRecipeCellclass. All of the controls are set to a style that has not been declared elsewhere through the use of the
DynamicResourcekeyword. Then in the code-behind, the key the
DynamicResourcewas set to is set to be equal to a style that is defined within the app.
Effects and Native Views - The key to this demo, other than the actual creation of the effect in the platform project, is to create a
RoutingEffectin the core project. This class will subclass
RoutingEffectand then in the base constructor pass in the
EffectName(both of which are defined in the platform project). That
RoutingEffectcan then be accessed from XAML, and added to the control's