Views and view trees

Understand View, Panel, ContentView, ItemView, and their UIKit peers.

Every visible SkeleKit element derives from View. A view stores layout, visual, interaction, and accessibility state, and owns one lazily-created native UIKit view. Constructing a SkeleKit view does not immediately add a UIView to the screen; the native tree is created when the page is hosted.

View card = new Border
{
    Padding = 16,
    CornerRadius = 12,
    Background = Colors.SecondaryBackground,
    Child = new Label
    {
        Text = "Account",
        TextStyle = TextStyle.Headline
    }
};

View.Native exposes the UIKit view after realization. IsRealized tells you whether that native peer currently exists. Most application code should configure the SkeleKit object instead of changing Native directly, because later property updates need to remain synchronized.

The sizing and safe areas guide explains how these views are measured once they are hosted.

Containers

Panel is the base for elements that own several children. Its Children property is a ViewCollection, so object and collection initializers can describe the hierarchy directly:

new StackPanel
{
    Padding = new Thickness(20),
    Spacing = 12,
    Children =
    {
        new Label { Text = "Profile" },
        new Button { Text = "Edit" }
    }
};

Adding, removing, moving, or replacing a child updates the native hierarchy and invalidates layout. A child has one Parent; adding the same view to two panels is not supported.

Border owns one Child, while ScrollView and ContentView expose one Content view. Assigning a new child replaces the previous one.

Pages and item views

ContentView represents a full screen hosted by the application shell. It owns the page content, navigation chrome, lifecycle callbacks, and access to navigation and platform services.

ItemView<T> is the reusable cell type used by CollectionView. Its BindingContext is the current item, and its Bind helpers create item bindings. See data and templates for the complete collection setup.

sealed class ContactRow : ItemView<Contact>
{
    public ContactRow()
    {
        Content = new Label
        {
            Text = Bind(contact => contact.Name)
        };
    }
}

Cells are recycled. Build the element tree once in the constructor and express item-specific values through bindings instead of replacing the tree for every item.

Binding context inheritance

BindingContext flows from a parent to its descendants unless a child sets its own context. ContentView<TViewModel> sets the page context to its ViewModel, and ItemView<T> replaces it with the collection item. Moving a view to a different parent reattaches its bindings to the new inherited context.

Native escape hatches

Use View.Native when you need a native property that the wrapper does not expose. Use NativeView when an existing UIView should become part of a SkeleKit tree. A page also exposes its native controller through ContentView.Controller after it is hosted. The native interop guide covers ownership and lifecycle boundaries.

These are escape hatches, not separate layout systems. The SkeleKit view still owns its measured size and position.