Xamarin.Forms Guides | Samples

Xamarin.Forms.VisualElement.OnSizeRequest Method

This method is called during the measure pass of a layout cycle to get the desired size of an element.

Syntax

[System.Obsolete("Use OnMeasure")]
protected virtual SizeRequest OnSizeRequest (Double widthConstraint, Double heightConstraint)

Parameters

widthConstraint
The available width for the element to use.
heightConstraint
The available height for the element to use.

Returns

A SizeRequest which contains the desired size of the element.

Remarks

The results of this method will be (-1, -1) if the element has not yet been realized with a platform specific backing control. Overriding this method does not require a call to the base class so long as a valid SizeRequest is returned.

Requirements

Namespace: Xamarin.Forms
Assembly: Xamarin.Forms.Core (in Xamarin.Forms.Core.dll)
Assembly Versions: 1.0.0.0, 1.1.0.0, 1.2.0.0, 1.3.0.0, 1.4.0.0, 1.5.0.0, 2.0.0.0