liveBook · Manning

PlatformView

As explained in .NET MAUI in Action

PlatformView is a handler property that exposes the native platform control associated with a .NET MAUI view.

PlatformView is a handler property that exposes the native control mapped to a .NET MAUI view. Handlers connect cross-platform abstractions to platform-specific implementations, allowing targeted UI customization when the shared API is not enough. section 11.3.1

Figure 11.11 Cross-platform controls are described by interfaces, and virtual views implement them as controls in the .NET MAUI UI layer. Handlers map the abstractions to platform-specific implementations.

Follow the mapping from a cross-platform control through its virtual view and handler to the native platform control. section 11.3.1

Use PlatformView when adding platform-specific handler logic:

  • Append a mapping to the relevant handler and restrict it to the custom view, such as BorderlessEntry. section 11.3.3
  • Separate platform branches with compiler directives such as ANDROID, WINDOWS, and IOS || MACCATALYST. section 11.3.3
  • Use handler.PlatformView to change native properties; for Android, the mapped Entry control is an AppCompatEditText. section 11.3.3
  • Inspect the native control's available properties and methods with IntelliSense when determining the required customization. section 11.3.3

Removing an Android Entry border

Inside an EntryHandler mapping, set handler.PlatformView.Background to null and call SetBackgroundColor with Android.Graphics.Color.Transparent. Equivalent iOS, macOS, and Windows branches modify each platform's border and background properties. section 11.3.3 section 11.3.3

How .NET MAUI in Action covers it

How deep it goes
Explains the abstraction-to-native mapping and demonstrates property changes, but defers broader native-control discovery to platform knowledge and IntelliSense.
Examples
Uses a BorderlessEntry example with Android AppCompatEditText, iOS and macOS text fields, and Windows text controls.
What it assumes
Assumes basic .NET MAUI controls and handlers while explaining from zero how abstractions reach native platform implementations.
What you can do after
Apply it via .NET MAUI handler mappings to modify native control properties on selected platforms.
How it connects
Connects handlers, virtual views, handler mappings, compiler directives, native controls, and platform-specific UI properties.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of .NET MAUI in Action. The section links point to the parts of the book it draws on.