Partager via


XRValue (Windows Embedded CE 6.0)

1/6/2010

This class describes both the value type and the actual value of a dependency property or attached property in Silverlight for Windows Embedded.

XRValue is used for passing values of dependency properties or attached properties through methods in Silverlight.

Syntax

class XRValue
{
public:
  XRValue()
  {
    SetNull();
  }

  void SetNull()
  {
    vType = VTYPE_NONE; 
    CornerRadiusVal.BottomLeft = 0;
    CornerRadiusVal.BottomRight = 0;
    CornerRadiusVal.TopLeft = 0;
    CornerRadiusVal.TopRight = 0;
  }

  VALUE_TYPE vType;

  union
  {
    float FloatVal;
    int IntVal;
    bool BoolVal;
    unsigned int UIntVal;
    COLORREF ColorVal;
    const WCHAR* pReadOnlyStringVal;
    BSTR bstrStringVal;
    XRPoint PointVal;
    XRRect RectVal;
    XRThickness ThicknessVal;
    XRSize SizeVal;
    XRGridLength GridLengthVal;
    XRCornerRadius CornerRadiusVal;
    IXRDependencyObject* pObjectVal;
  };

};

Methods

Method Description

XRValue()

Constructor that can be used inline to create a new XRValue object.

SetNull()

Helper method that can be used inline to reset this XRValue object to a null object reference.

Member Variables

Member variable Description

vType

VALUE_TYPE (Silverlight for Windows Embedded) enumerated type that indicates the type code for this XRValue, which governs how the value of the other member variable is interpreted.

FloatVal

This member variable is used to pass a 32-bit float value. FloatVal is valid only if vType is VTYPE_FLOAT.

IntVal

This member variable is used to pass a 32-bit signed integer value. IntVal is valid only if vType is VTYPE_INT.

BoolVal

This member variable is used to pass a Boolean value, where 0 indicates false, and any other value indicates true.

UIntVal

This member variable is used to pass a 32-bit integer enumeration.

ColorVal

This member variable is used to pass an RGB COLORREF value.

pReadOnlyStringVal

This member variable is used to pass a length-specified read-only Unicode string.

bstrStringVal

This member variable is used to pass a BSTR string value.

PointVal

This member variable is used to pass an XRPoint structure that contains a pair of float values.

RectVal

This member variable is used to pass an XRRect structure that contains left, top, right, and bottom values.

ThicknessVal

This member variable is used to pass an XRThickness structure that contains left, top, right, and bottom values.

SizeVal

This member variable is used to pass an XRSize structure that contains a pair of float values.

GridLengthVal

This member variable is used to pass an XRGridLength structure that specifies row and column dimensions.

CornerRadiusVal

This member variable is used to pass an XRCornerRadius that describes the radius of the rectangle's corners.

pObjectVal

This member variable is used to pass an IXRDependencyObject derived object.

Remarks

Many methods in Silverlight for Windows Embedded deal with attached properties and dependency properties without specifically identifying each property name and value. By using XRValue to represent a property value, you can select from many different value types that are not fixed by the parameter definition of a method. The XRValue object contains information about the object type that was passed into the method. This is helpful when registering new dependency properties or attached properties for a custom user control, retrieving a specific dependency property or attached property value, setting a new value for a property, or implementing a callback method that indicates that a property value has changed.

The VALUE_TYPE (Silverlight for Windows Embedded) enumerated type indicates which member of the unnamed union is valid for use by pStringVal in interpreting its value.

When you receive an XRValue, check the vType member to determine which member variable contains valid data.

Example

The following code example shows a sample method implementation that demonstrates the use of creating and passing an XRValue object.

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 "XamlRuntime.h"
#include "XRCustomControl.h"

void SetValue(DEPENDENCY_PROPERTY_ID propID, IXRCustomUserControl* pCustomControl)
{
  float pValue = 100;
  XRValue xrValue;
  xrValue.vType = VTYPE_FLOAT;
  xrvalue.pFloatVal = pValue;

  pCustomControl.SetPropertyValue(propID, &xrValue);
}

For more information about the programming element DEPENDENCY_PROPERTY_ID that was used in the previous code example, see IXRApplication::RegisterDependencyProperty.

.NET Framework Equivalent

None.

Requirements

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

See Also

Reference

Classes for Application Management
FreeXRValue