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

Using templated components

In constructing a Razor component, component parameters serve as the communication channels between parent and child components. While discussing nested components, we brought attention to a special ChildContent component parameter of the RenderFragment type. This parameter enables the parent component to set the content of the child component. For instance, the content of MenuItem in the following code can be assigned an HTML string:

<MenuItem Id="@_dialogDeleteId">
  <strong>Delete</strong>
</MenuItem>

We are able to achieve this as MenuItem defines the following component parameter, which can be observed in Listing 10.11:

[Parameter]
public RenderFragment ChildContent { get; set; }

If we want to explicitly specify the ChildContent parameter, we can achieve this as follows:

<MenuItem Id="@_dialogDeleteId">
  <ChildContent>
    <strong>Delete</strong>
  </ChildContent...
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