The following code creates a component that renders a ContentPage with title "Home Page":
Line 3. Every component must override the Render method and return the visual tree of the component
Line 5. The ContentPage visual node pairs with the ContentPage native control.
Line 6. The Title property sets the title of the page and updates the Title dependency property on the native page.
You can also pass the title to the Constructor:
Line 5. The title of the page is set by passing it to the ContentPage constructor.
Running the app you should see an empty page titled "Home Page"
You can build any complex UI in the render method of the component but often it's better to compose more than one component to create a page or app.
For example, consider this component:
We could create a component like this:
and reuse it on the main page as shown in the following code:
Reusing components is a key feature in MauiReactor: decomposing a large page into small components that are easier to test is also beneficial to the overall performance of the application.