Derivation and attributes of Xamarin XAML language tutorial basic pages ContentPage footprint content pages
Derivation and attributes of Xamarin XAML language tutorial basic pages ContentPage footprint content pages
3. Derivation of content pages
The ContentPage page is derived from Page and is the parent of other pages. The derived diagram is shown in figure 14.6.
Figure 14.6 derivative relationship
Note: ContentPage pages can be used as an element of other pages.
4. Attribute
The ContentPage page defines a property Content property that sets the content of the page, which the developer can set to a control, a view, or a layout.
(1) developers can set the Content attribute to button control, label control, etc., such as the following code snippet:
In this code, we set the Content property to the label control.
Note: in the chapter on attributes and attribute values, we mentioned that content attributes can be omitted. The Content property is a content property, so we omitted it in the code.
(2) the Content property can be set not only to a control, but also to a content view, such as the following code:
(3) the Content property of a ContentPage page can also be set to an object. When we set it as a control or a content view, we see only one element on the page. If the developer wants to have multiple elements on the page, they need to use the layout, in which there can be multiple views or controls. Such as the following code:
In this code, we set the layout as a stack layout and place five more label controls in this layout.