liveBook · Manning

HeightRequest

As explained in .NET MAUI in Action

HeightRequest is a .NET MAUI visual-element property specifying a preferred height subject to layout constraints.

HeightRequest sets a view’s requested height in .NET MAUI. Unlike the read-only Height property, it supplies a height value that layout can use. Values are expressed in device-independent units (DIUs), helping interfaces scale across displays with different resolutions and physical sizes. section 4.4.1

Use HeightRequest when you need consistent sizing or want to centralize visual dimensions:

  • Read Height when you need the view’s resulting size; set HeightRequest when you want to request a size. section 4.4.1
  • Prefer DIUs instead of pixel coordinates so a requested height remains suitable across different screen resolutions and sizes. section 4.4.1
  • Put HeightRequest in a style when several controls should share the same height. section 10.1.1

Give every button a consistent height

In a Button style, add <Setter Property="HeightRequest" Value="50" />. The same style changes CornerRadius to 25 and MinimumWidthRequest to 100, producing consistently sized branded buttons on the LoginPage. section 10.1.1

How .NET MAUI in Action covers it

How deep it goes
Explains the read-only Height distinction, DIU sizing rationale, and a style setter, but does not detail layout measurement internals.
Examples
Demonstrates a Button style assigning HeightRequest 50 alongside CornerRadius and MinimumWidthRequest changes.
What it assumes
Assumes basic .NET MAUI views and properties while teaching the difference between measured dimensions and requested dimensions.
What you can do after
Apply it via XAML styles to request consistent control heights using device-independent units.
How it connects
Connects HeightRequest with Height, WidthRequest, VisualElement, styles, Setter, and device-independent units.

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.