Reader small image

You're reading from  .NET MAUI Cross-Platform Application Development - Second Edition

Product typeBook
Published inMar 2024
Reading LevelBeginner
PublisherPackt
ISBN-139781835080597
Edition2nd Edition
Languages
Right arrow
Author (1)
Roger Ye
Roger Ye
author image
Roger Ye

Roger Ye is an embedded system programmer who has great interest in virtualization, Android, and cross-platform technologies. His professional experience includes working with major companies like Motorola, Emerson, Intel, and EPAM, where he held the position of Engineering Manager. At Motorola and Emerson, he worked on embedded system projects for mobile devices and telecommunication infrastructures. He is now an engineering manager at EPAM, working with a team to deliver digital solutions for diverse clients.
Read more about Roger Ye

Right arrow

Understanding Razor syntax

Blazor applications are composed of Razor components. As discussed in Chapter 3, User Interface Design with XAML, XAML is a language that has its roots in XML. UI elements based on XAML consist of XAML pages and their corresponding C# code-behind files. Razor components closely resemble this pattern, with the primary difference being that Razor employs HTML as its markup language and C# code can be directly embedded within the HTML. Alternatively, we can opt to separate the C# code into a code-behind file, thus maintaining a clear distinction between the UI and its underlying logic.

Code blocks in Razor

To create the simplest Razor component, it would appear as follows:

<h3>Hello World!</h3>
@code {
  // Put your C# code here
}

In the previous example, we can design our page similarly to an HTML page while incorporating programming logic within a code block. Razor pages or Razor components are generated as C# classes, with the...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
.NET MAUI Cross-Platform Application Development - Second Edition
Published in: Mar 2024Publisher: PacktISBN-13: 9781835080597

Author (1)

author image
Roger Ye

Roger Ye is an embedded system programmer who has great interest in virtualization, Android, and cross-platform technologies. His professional experience includes working with major companies like Motorola, Emerson, Intel, and EPAM, where he held the position of Engineering Manager. At Motorola and Emerson, he worked on embedded system projects for mobile devices and telecommunication infrastructures. He is now an engineering manager at EPAM, working with a team to deliver digital solutions for diverse clients.
Read more about Roger Ye