FrameworkElement..::.Height Property
This page is specific to:Microsoft Version:3.03.5Silverlight 34.0
.NET Framework Class Library for Silverlight
FrameworkElement..::.Height Property

Gets or sets the suggested height of a FrameworkElement.

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

'Usage

Dim instance As FrameworkElement
Dim value As Double

value = instance.Height

instance.Height = value

'Declaration

Public Property Height As Double
    Get
    Set
<frameworkElement Height="double"/>

Property Value

Type: System..::.Double
The height of the object, in pixels. The default is Double..::.NaN. Except for the special Double..::.NaN value, this value must be equal to or greater than 0. See Remarks for upper-bound information.
Remarks

Dependency property identifier field: HeightProperty

Height is one of three writable properties on FrameworkElement that specify height information. The other two are MinHeight and MaxHeight. If there is a conflict between these values, the order of application for actual height determination is that first MinHeight must be honored, then MaxHeight, and finally, if it is within bounds, Height.

Several of the FrameworkElement derived objects are also derived from Shape. Not all of the Shape classes typically use Height or Width to specify their appearance, and instead use specific properties that might define a set of points. In this case a Height or Width is calculated, but is not typically set directly. See Shapes and Drawing.

Custom classes might have similar considerations where the class might have properties that are more meaningful for specifying dimensions than are Height or Width. In this case Height or Width will both still be available as members and are settable, even though the desirable behavior might be to not enable Height or Width setting. In critical cases, it might be useful to shadow the Height and Width properties to prevent them from being set directly by consumers of the class.

If the object where Height or Width properties are set is a child object within some other parent's child collection, then setting Height or Width to a value is only a suggested value for Silverlight layout. The layout system as well as the particular layout logic of the parent's class will use the value as a nonbinding input during the layout process, and might have to clip, resize the object, resize the container, or some combination of these behaviors that spans multiple participating objects in layout. In practical terms, a FrameworkElement is almost always the child object of something else; even when you set the Height on the page root. (For the page root, that value is used when the underlying application model establishes the basic rendering assumptions that create the Silverlight content area in the hosting browser application.) 

The return value of this property is always the same as any value that was set to it. In contrast, the value of the ActualHeight may vary. This can happen either statically because the layout rejected the suggested size for some reason, or momentarily. The layout system itself works asynchronously relative to the property system's set of Height and may not have processed that particular sizing property change yet.

Negative values for Height are not permitted. Non-integral values for Height are technically permitted, but should generally be avoided and are normally rounded by the default layout rounding behavior. See Layout Rounding.

In addition to the validation check, there is a nondeterministic upper value bound for Height that is enforced by the layout system (this is a very large number, larger than Single..::.MaxValue but smaller than Double..::.MaxValue). If you exceed this bound, the object will not render, and no exception is thrown. Do not set Height to a value that is significantly larger than the maximum size of any possible visual display, or you might exceed this nondeterministic upper bound.

"Auto" Layout and Double.NaN

The default value of Height and Width is not 0, it is Double..::.NaN. Height and Width support the ability to be an unset "Auto" value. Because Height and Width are Double values, Double..::.NaN is used as a special value to represent this "Auto" behavior. The layout system interprets the "Auto" value to generally mean that the object should be sized to the available size in layout, rather than to a specific pixel value.

If you want the "Auto" behavior for an object when it is used in layout, leave Height and Width unset at their Double..::.NaN default value. If you have previously set values and want to reenable the "Auto" behavior, set Height and Width specifically to Double..::.NaN.

Although not a common practice except for perhaps in visual state templates, you can also explicitly set Height and Width attributes in XAML to be the string Auto rather than a Double value. Setting Auto in Silverlight XAML is a special behavior of the Silverlight 3 XAML parser, not a TypeConverter behavior.

Platforms

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

See Also

Reference

Other Resources

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View