Share via

Width Property (UIElement)

Gets or sets the width of the object.

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

Property Value


The width of the object.

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


Many of the UIElement 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. For details, see Shapes and Drawing in Silverlight Overview.

TextBlock is a container object that displays text within it. The size of that text can influence the size of the rendered TextBlock, so TextBlock supports two additional properties that expose that calculated size, ActualHeight and ActualWidth. For details, see Text and Fonts Overview.

Applies To

Canvas, Ellipse, Glyphs, Image, InkPresenter, Line, MediaElement, Path, Polygon, Polyline, Rectangle, TextBlock

See Also

Object Layout in Silverlight