UIElement::DesiredSize Property

Gets the size that this UIElement computed during the measure pass of the layout process.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)

No code example is currently available or this language may not be supported.

Property Value

Type: System.Windows::Size
The size that this UIElement computed during the measure pass of the layout process.

DesiredSize values are set by the layout system as part of calls to Measure.

DesiredSize values are useful if you are implementing layout override behavior, in particular during the arrange pass. Depending on the scenario, DesiredSize might be fully respected by your layout logic, constraints on DesiredSize might be applied, and such constraints might also change other characteristics of either the parent or child in layout. For example, a control that supports scrollable regions (but chooses not to derive from controls that already enable scrollable regions) could compare available size to DesiredSize. The control could then set an internal state that enabled scrollbars in the UI for that control. Or, DesiredSize could potentially also be ignored in certain layout scenarios.

You would not typically get the value of DesiredSize outside of a context where your code has already called Measure on that same element as part of the measure pass of layout, or called something that initiates a full layout pass such as UpdateLayout. Otherwise, there is no guarantee that the value held by DesiredSize is relevant.

The following example queries DesiredSize as part of the child iteration for an ArrangeOverride implementation.

No code example is currently available or this language may not be supported.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show: