View

Base of every SkeleKit element: owns one lazily-created native view and takes part in the measure/arrange engine.
public abstract class View

Constructors

Applies the app's implicit theme styles for this view's type.

protected View()

Properties

AccessibilityHint

Extra VoiceOver context describing what activating the view does, or null for none.

Type: string?

public string? AccessibilityHint { get; set; }

AccessibilityIdentifier

Identifier for UI tests. Never read to the user.

Type: string?

public string? AccessibilityIdentifier { get; set; }

AccessibilityLabel

Text VoiceOver reads for the view, or null for the control's own default.

Type: Bindable<string?>

public Bindable<string?> AccessibilityLabel { get; set; }

AccessibilityTraits

Extra traits VoiceOver applies on top of the control's own (Header, Selected, ...).

Type: AccessibilityTraits

public AccessibilityTraits AccessibilityTraits { get; set; }

AccessibilityValue

The current value VoiceOver reads after the label (a slider's percentage), or null for the control's own default.

Type: Bindable<string?>

public Bindable<string?> AccessibilityValue { get; set; }

AnchorPoint

The pivot for Rotation and Scale, in unit coordinates.

(0.5, 0.5) is the center (the default), (0, 0) the top-left corner, (1, 1) the bottom-right.

Type: Point

public Point AnchorPoint { get; set; }

ArrangedBounds

Frame from the last arrange pass, in the parent's coordinates (margin excluded).

Type: Rect

public Rect ArrangedBounds { get; private set; }

Background

The background fill: a color, gradient or material, or null for transparent.

Type: Brush?

public Brush? Background { get; set; }

BindingContext

The object bindings resolve against. Inherited from the parent unless set explicitly.

Type: object?

public object? BindingContext { get; set; }

ClipsToBounds

When true, content is clipped to the bounds and corner radius.

False by default so child shadows and effects can extend beyond layout bounds. Scrolling views clip by default because their bounds are a viewport.

Type: bool

public bool ClipsToBounds { get; set; }

ContextMenu

Entries in the view's long-press context menu. Empty for none.

Type: IList<MenuAction>

public IList<MenuAction> ContextMenu { get; }

CornerRadius

Corner radius in points applied to the layer.

Type: double

public double CornerRadius { get; set; }

DesiredSize

Size requested by the last measure pass, including Margin.

Type: Size

public Size DesiredSize { get; private set; }

DoubleTapCommand

Command invoked when the view is double-tapped.

Type: ICommand?

public ICommand? DoubleTapCommand { get; set; }

DoubleTapCommandParameter

The parameter passed to DoubleTapCommand.

Type: object?

public object? DoubleTapCommandParameter { get; set; }

Haptics

The application's haptic feedback service.

ViewModels take IHaptics by constructor instead.

Type: IHaptics

protected IHaptics Haptics { get; }

Height

Explicit height in points, or NaN to size to content.

This constrains layout bounds but does not imply clipping. Set ClipsToBounds when children should not draw beyond an explicitly constrained container.

Type: double

public double Height { get; set; }

HorizontalAlignment

How the view is placed within the horizontal space its parent gives it.

Type: HorizontalAlignment

public HorizontalAlignment HorizontalAlignment { get; set; }

IgnoresSafeArea

Edges this view is allowed to extend past the safe area.

A scrolling view still keeps its content inside it, so only the scroll passes under the bar.

Type: SafeAreaEdges

public SafeAreaEdges IgnoresSafeArea { get; set; }

IsAccessibilityElement

Overrides whether VoiceOver treats the view as one element, or null for the control's own default.

Type: bool?

public bool? IsAccessibilityElement { get; set; }

IsEnabled

Whether the view responds to touches.

Type: Bindable<bool>

public Bindable<bool> IsEnabled { get; set; }

IsFocused

Whether this view currently holds keyboard focus.

Type: bool

public bool IsFocused { get; }

IsRealized

Whether the native view has been created yet.

Type: bool

public bool IsRealized { get; }

IsVisible

When false the view takes no space and is hidden natively.

Type: Bindable<bool>

public Bindable<bool> IsVisible { get; set; }

LongPressCommand

Command invoked when the view is held down for LongPressDuration.

Type: ICommand?

public ICommand? LongPressCommand { get; set; }

LongPressCommandParameter

The parameter passed to LongPressCommand.

Type: object?

public object? LongPressCommandParameter { get; set; }

LongPressDuration

How long a press must be held to count as a long press, in seconds.

Type: double

public double LongPressDuration { get; set; }

Margin

Empty space around the view, outside its bounds.

Type: Thickness

public Thickness Margin { get; set; }

MaxHeight

Maximum height in points.

Type: double

public double MaxHeight { get; set; }

MaxWidth

Maximum width in points.

Type: double

public double MaxWidth { get; set; }

MinHeight

Minimum height in points.

Type: double

public double MinHeight { get; set; }

MinWidth

Minimum width in points.

Type: double

public double MinWidth { get; set; }

Native

The underlying UIKit view, created on first access. Primary escape hatch to UIKit.

Type: UIView

public UIView Native { get; }

The application's navigator.

ViewModels take INavigator by constructor instead.

Type: INavigator

protected INavigator Navigator { get; }

Opacity

Opacity from 0 (transparent) to 1 (opaque).

Type: double

public double Opacity { get; set; }

Panned

Invoked as the view is dragged.

Drive an Animator from it to make an animation interactive.

Type: Action<PanGesture>?

public Action<PanGesture>? Panned { get; set; }

Parent

The panel this view sits in, or null when it is a root or unparented.

Type: View?

public View? Parent { get; private set; }

Pinched

Invoked as the view is pinched.

Feed the scale into Scale to zoom it.

Type: Action<PinchGesture>?

public Action<PinchGesture>? Pinched { get; set; }

PointerEffect

The iPad pointer effect shown when a trackpad or mouse hovers this view, or None (the default).

Type: PointerEffect

public PointerEffect PointerEffect { get; set; }

Pressed

Invoked with true on touch-down anywhere in the view, false on release or cancel.

Child controls still receive their touches.

Type: Action<bool>?

public Action<bool>? Pressed { get; set; }

Rotated

Invoked as the view is rotated with two fingers.

Feed the degrees into Rotation to turn it.

Type: Action<RotateGesture>?

public Action<RotateGesture>? Rotated { get; set; }

Rotation

Rotates the view about its AnchorPoint, in degrees. Does not affect layout.

Type: double

public double Rotation { get; set; }

Scale

Scales the view about its center, 1 being its laid-out size. Does not affect layout.

Type: double

public double Scale { get; set; }

Shadow

A drop shadow behind the view, or null for none.

Setting a shadow prevents CornerRadius from enabling clipping; an explicit ClipsToBounds still hides it.

Type: Shadow?

public Shadow? Shadow { get; set; }

Sharer

The application's share sheet.

ViewModels take ISharer by constructor instead.

Type: ISharer

protected ISharer Sharer { get; }

Style

A style applied the moment it is assigned.

Put it first in an object initializer; later assignments override it.

Type: IStyle?

public IStyle? Style { get; set; }

SystemPicker

The application's photo and document pickers.

ViewModels take ISystemPicker by constructor instead.

Type: ISystemPicker

protected ISystemPicker SystemPicker { get; }

TapCommand

Command invoked when the view is tapped.

Type: ICommand?

public ICommand? TapCommand { get; set; }

TapCommandParameter

The parameter passed to TapCommand.

Type: object?

public object? TapCommandParameter { get; set; }

Tint

The tint color for this view and everything under it.

Inherited from the parent unless set here, falling back to the app tint.

Type: Color?

public Color? Tint { get; set; }

Translation

Shifts the view from where layout put it, in points. Does not affect layout.

Type: Point

public Point Translation { get; set; }

VerticalAlignment

How the view is placed within the vertical space its parent gives it.

Type: VerticalAlignment

public VerticalAlignment VerticalAlignment { get; set; }

Width

Explicit width in points, or NaN to size to content.

Type: double

public double Width { get; set; }

Methods

AddNativeGesture

Adds a native gesture recognizer without forcing the view to realize.

This is an escape hatch for gestures the library does not wrap. The recognizer is retained and attached whenever the view's native peer is realized. The caller owns any separate target or delegate objects used by the recognizer.

public void AddNativeGesture(
  UIGestureRecognizer gesture)
ParameterSummary
UIGestureRecognizer gestureThe native gesture recognizer to retain and attach.

Animate

Animates the property changes made inside changes.

public static void Animate(
  double seconds,
  Action changes)
ParameterSummary
double secondsThe animation duration, in seconds.
Action changesThe property changes to animate.

Animate

Animates the property changes made inside changes, following animation.

For an animation the user can grab mid-flight, create an Animator instead.

public static void Animate(
  Animation animation,
  Action changes,
  Action<bool>? completed = null)
ParameterSummary
Animation animationThe timing and easing to use.
Action changesThe property changes to animate.
(optional) Action<bool>? completedCalled when the animation completes, with whether it finished normally.

Arrange

Second pass: positions the view within its slot, honoring margin and alignment.

public void Arrange(
  Rect finalRect)
ParameterSummary
Rect finalRectThe final slot in the parent's coordinates.

ArrangeOverride

Content arrangement. Panels override to place their children.

protected virtual Size ArrangeOverride(
  Size finalSize)
ParameterSummary
Size finalSizeThe final size available for the view's content.

Returns

  • Size: The arranged content size.

Focus

Gives the view keyboard focus, raising the keyboard for a text control. No-op until realized.

public void Focus()

InvalidateMeasure

Drops the cached measurement here and up the tree, and asks the root host for a layout pass.

public void InvalidateMeasure()

InvalidateSubtree

Drops every cached measurement in this subtree.

For changes that hit leaves directly, like a dynamic-type resize.

public void InvalidateSubtree()

LayoutNow

Runs any pending layout right now. Call it inside an Animator's changes to animate a layout property.

Layout properties such as Width or Margin reach the native frame on the next layout pass, after an animation block closes. Calling this method inside the animation keeps them from snapping; Animate does this automatically.

public static void LayoutNow()

Measure

First pass: computes DesiredSize for the space the parent offers.

public void Measure(
  Size available)
ParameterSummary
Size availableThe size available from the parent.

MeasureOverride

Content measurement. Panels recurse; controls delegate to the native SizeThatFits.

protected virtual Size MeasureOverride(
  Size availableSize)
ParameterSummary
Size availableSizeThe size available for the view's content.

Returns

  • Size: The desired content size.

Realize

Builds the native view (if needed) and realizes children and bindings.

public UIView Realize()

Returns

  • UIView: The realized native view.

Unfocus

Takes keyboard focus away, dismissing the keyboard.

public void Unfocus()

Unrealize

Tears down the native view and children deterministically (no finalizers).

public void Unrealize()