Freigeben über


Width (UIElement)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the width of an object.

<object Width="Double"  .../>
value = object.Width
object.Width = value

Property Value

Type: Double

The width of the object, in pixels.

This property is read/write. The default value is 0.

Managed Equivalent

Width

Remarks

Many of the UIElement derived objects are also derived from Shape. Not all the Shape classes typically use Height or Width to specify their appearance. Instead, they use specific properties that might define a set of points. In this case, a Height or Width is calculated but not typically set directly.

TextBlock is a container object that displays text within it. The size of that text can influence the size of the rendered TextBlock. Therefore, TextBlock supports two additional properties that expose that calculated size: ActualHeight and ActualWidth.

Applies To

Border (Silverlight 2)

Canvas

Ellipse

Glyphs

Image

InkPresenter

Line

MediaElement

PasswordBox (Silverlight 2)

Path

Polygon

Polyline

Popup (Silverlight 2)

Rectangle

StackPanel (Silverlight 2)

TextBlock

TextBox (Silverlight 2)

See Also

Reference