Rectangle Class Home
This page is specific to:Microsoft Version:3.03.5Silverlight 34.0
.NET Framework Class Library for Silverlight
Rectangle Class

Draws a rectangle shape, which can have a stroke and a fill.

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

'Usage

Dim instance As Rectangle

'Declaration

Public NotInheritable Class Rectangle _
    Inherits Shape
<Rectangle .../>
Remarks

A Rectangle cannot support child objects. If you want a rectangular region that contains other objects, you can use a Canvas. You can also use a composite geometry, but in this case you would probably use RectangleGeometry rather than Rectangle. For details about how to create composite geometries, see Geometries.

The fill for a Rectangle or any other shape that has a fill area does not have to be a solid color. It can be any Brush, including ImageBrush or VideoBrush. For more information, see Brushes.

Examples

The following example shows how to create a Rectangle.

Run this sample

<Canvas>  
     
  <Rectangle Width="100" Height="100" Fill="Blue" Stroke="Red" 
   Canvas.Top="20" Canvas.Left="20" StrokeThickness="3" />

</Canvas>
Inheritance Hierarchy

System..::.Object
  System.Windows..::.DependencyObject
    System.Windows..::.UIElement
      System.Windows..::.FrameworkElement
        System.Windows.Shapes..::.Shape
          System.Windows.Shapes..::.Rectangle
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
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