IXRRectangle (Windows Embedded CE 6.0)

1/6/2010

This class represents a rectangle shape, which is outlined with a stroke and uses a brush to fill its rectangular region.

Syntax

class IXRRectangle : public IXRShape

Methods

Method Description

IXRRectangle::GetRadiusX

Retrieves the x-axis radius of the ellipse that is used to round the corners of this rectangle object.

IXRRectangle::GetRadiusY

Retrieves the y-axis radius of the ellipse that is used to round the corners of this rectangle object.

IXRRectangle::SetRadiusX

Sets the new x-axis radius of the ellipse that is used to round the corners of this rectangle object.

IXRRectangle::SetRadiusY

Sets the new y-axis radius of the ellipse that is used to round the corners of this rectangle object.

Remarks

An IXRRectangle cannot support child objects. If you want to create a rectangular region that contains other objects, instead use IXRCanvas. You can also use a composite geometry as data to define a rectangular region, but in this case, you should use IXRRectangleGeometry instead of IXRRectangle.

The fill for a rectangle shape, or for any other shape that has a fill area, does not have to be a solid color. It can be any brush, including an image brush or a video brush. For more information, see IXRBrush.

You can also define a rectangle shape in Microsoft Silverlight 2 XAML. For information about the differences between XAML in Silverlight for Windows Embedded and Silverlight 2, see Differences Between Silverlight for the Web and Silverlight for Windows Embedded. For more information about how to define this element in the source XAML for your application, see Rectangle Class on MSDN.

Example

The following code example shows how to create a rectangle object, set properties on it, and add it to the content of an item in the element tree. It uses smart pointers and method overloads that help ensure type-safety, which is covered in Type-Safety in Silverlight for Windows Embedded.

Important

For readability, the following code example does not contain security checking or error handling. Do not use the following code in a production environment.

#include <windows.h>
#include <XamlRuntime.h>
#include <XRPtr.h>

void AddRectangleToExistingElementTree(IXRApplication* pApplication, IXRVisualHost * pVisualHost, IXRSolidColorBrush * pMyBlueBrush) 
{
    //  Note: This code uses smart pointers to ensure that 
    // all interfaces are released
   // (see Type-Safety in Silverlight for Windows Embedded topic)
    IXRRectanglePtr pRectangle;
    IXRFrameworkElementPtr pRootElement;
    IXRStackPanelPtr pStackPanel;
    IXRUIElementCollectionPtr pChildrenCollection;

    // Create a new rectangle from the IXRApplication object
    //
    //  Note: CreateObject is a Helper Template Overload Method 
   // (see Type-Safety in Silverlight for Windows Embedded topic)
    pApplication->CreateObject(IID_IXRRectangle, &pRectangle);  

    // Here's where you would set the properties you want on the rectangle
    // (for example, width, height, fill, border, etc.)
    // 
    pRectangle->SetWidth(10);
    pRectangle->SetFill(pMyBlueBrush);

    // Now get the root element (as stack panel) from your visual host 
    //and add the rectangle as a 
    // child in the panel's collection
    //

    // First find the stack panel named "MyStackPanel"
    //
    pVisualHost->GetRootElement(&pRootElement); 
    pRootElement->FindName(TEXT("MyStackPanel"), &pStackPanel);

    // Now get the children collection and add our new rectangle
    //
    pStackPanel->GetChildren(&pChildrenCollection);
    pChildrenCollection->Add(pRectangle, NULL);
}

The previous code example assumes that you have already created an application instance, parsed the XAML markup into an element tree, and obtained a pointer (pVisualHost) to the visual host. For more information on the programming elements used in this code example, see IXRApplication, IXRVisualHost, IXRStackPanel, XRPtr<Interface>, IXRApplication::CreateObject(IID,Object), and IXRUIElementCollection.

Inheritance Hierarchy

IXRDependencyObject

    IXRUIElement

        IXRFrameworkElement

            IXRShape

**                IXRRectangle**

.NET Framework Equivalent

System.Windows.Shapes.Rectangle

Requirements

Header XamlRuntime.h
sysgen SYSGEN_XAML_RUNTIME
Windows Embedded CE Windows Embedded CE 6.0 R3

See Also

Reference

Classes for UI Element Management

Other Resources