Chapter 6. Working with Razor Templates

In our previous chapter, we looked at how to work with the DataTemplateCustomRenderer by creating a C# class to layout your views beautifully within your applications, and how you will also get accustomed to working with the platform-specific APIs to extend the default behavior of Xamarin.Forms controls using custom renderers, by creating a custom picker.

You also learned how to use the Xamarin.Forms Effects API to customize the appearance and styling of native control elements for each platform, by implementing a custom renderer class, and looked at how to manipulate the visual appearance of data that is bound, using value and image converters.

In this chapter, you'll learn about the Razor HTML template engine and how you can use it to create a hybrid mobile solution. You'll learn how to build a book library mobile solution using the power of Razor templates, and learn how to create, and use models within your application and connect this up to an SQLite database to store, retrieve, update, and delete book details.

This chapter will cover the following topics:

  • Introduction to the Razor HTML template engine
  • How to build a hybrid mobile solution using Xamarin Studio
  • Incorporating SQLite.Net and creating a SQLite database wrapper
  • Creating the book database model
  • Creating the book listing main page
  • Creating the book listing add page
  • Creating the book listing edit page

Understanding the Razor template engine

The Razor templating engine was first introduced as part of the ASP.Net MVC architecture, and was originally designed to run on a web server to generate HTML files to be served to web browsers.

Since Razor made its first appearance on the development scene, the Razor templating engine has come a long way and now extends the standard HTML syntax, so that you can use C# to express the layout of your HTML files, and incorporate CSS style sheets and JavaScript easily.

Each Razor template has the ability to reference a Model class which can be of any custom type, and properties can be accessed directly from the template, by having the ability to mix HTML and C# syntax easily.

As you work through this chapter, you will see how, by working with Xamarin Studio, you can utilize the Razor HTML templating engine and be equipped with the flexibility of building cross-platform templated HTML views that use both JavaScript and CSS, as well as having access to the underlying platform APIs using the power of C#.

Note

For more information on using Razor syntax (C#) with ASP.NET web programming refer to the following URL: https://www.asp.net/web-pages/overview/getting-started/introducing-razor-syntax-c.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.189.228