liveBook · Manning

Attached property

As explained in .NET MAUI in Action

An attached property is a XAML property mechanism that lets one object provide position or configuration metadata for another object.

An attached property lets one object provide metadata for another. In .NET MAUI, Grid.Row and Grid.Column place controls within a Grid without making those properties ordinary Button or Label properties. section 5.1.2

Use attached properties when positioning views in a Grid:

  • Count rows and columns from zero: row 0 is the top, and column 0 is the left. section 5.1.2
  • Set Grid.Row and Grid.Column directly on any view placed in the Grid. section 5.1.2
  • Use Grid.ColumnSpan when a view, such as a display, should extend across multiple columns. section 5.1.2

Place a button in a Grid

A Button with Grid.Row="2" and Grid.Column="1" occupies the third row and second column. A calculator can reserve row 0 for its display and place buttons in later rows. section 5.1.2

<Button Grid.Row="2"
        Grid.Column="1"
        Text="Click me!" />

Inspect the minimal XAML example showing an attached property on a Button. section 5.1.2

How .NET MAUI in Action covers it

How deep it goes
Explains zero-based placement and demonstrates XAML, but does not examine the underlying property implementation.
Examples
Uses a calculator interface, numbered Grid coordinates, Button placement, and a Label spanning four columns.
What it assumes
Assumes basic XAML controls and Grid usage while teaching zero-based row and column placement.
What you can do after
Apply it via XAML to place views at specific Grid coordinates and span columns.
How it connects
Connects attached properties with XAML, Grid layout, views, row definitions, column definitions, and column spanning.

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.