Compartilhar via


XRValue (Compact 2013)

3/28/2014

This C++ class represents a value and stores both the value's type and its actual value.

Syntax

class XRValue

Constructors

Constructor

Description

XRValue() Constructor

Constructor that creates a new instance of XRValue and initializes its value type to VTYPE_NONE.

XRValue(ValueType&, bool) Constructor

Constructor that creates a new instance of XRValue with the supplied initial values.

XRValue(const XRValue&) Copy Constructor

Constructor that creates a new instance of XRValue from a preexisting version of XRValue.

Methods

Method

Description

XRValue::GetValue

Retrieves the current value from XRValue.

XRValue::SetNull

Sets the value type of this XRValue object to VTYPE_NONE, initializes all related values to 0, and sets ShouldFreeValuePointer to false.

XRValue::SetValue

Sets the new value of XRValue.

Member Variables

Member variable

Description

ShouldFreeValuePointer

Used to demote the transfer of ownership of the XRValue contents across function calls.

Ownership of the XRValue contents is passed to another function. The called function is responsible for calling FreeXRValue.

Calling FreeXRValue on an XRValue object without this flag set will be a no operation NOP.

vType

VALUE_TYPE (XAML 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

Passes a 32-bit float value. FloatVal is valid only if vType is VTYPE_FLOAT.

IntVal

Passes a 32-bit signed integer value. IntVal is valid only if vType is VTYPE_INT.

BoolVal

Passes a Boolean value, where 0 indicates false, and any other value indicates true. BoolVal is valid only if vType is VTYPE_BOOL.

UIntVal

Passes a 32-bit integer enumeration. UIntVal is valid only if vType is VTYPE_UINT.

ColorVal

Passes an RGB COLORREF value. ColorVal is valid only if vType is VTYPE_COLOR.

pReadOnlyStringVal

Passes a length-specified read-only Unicode string. pReadOnlyStringVal is valid only if vType is VTYPE_READONLY_STRING.

bstrStringVal

Passes a BSTR string value. bstrStringVal is valid only if vType is VTYPE_BSTR.

PointVal

Passes an XRPoint structure that contains a pair of float values. PointVal is valid only if vType is VTYPE_POINT.

RectVal

Passes an XRRect structure that contains left, top, right, and bottom values. RectVal is valid only if vType is VTYPE_RECT.

ThicknessVal

Passes an XRThickness structure that contains left, top, right, and bottom values. ThicknessVal is valid only if vType is VTYPE_THICKNESS.

SizeVal

Passes an XRSize structure that contains a pair of float values. SizeVal is valid only if vType is VTYPE_SIZE.

GridLengthVal

Passes an XRGridLength structure that specifies row and column dimensions. GridLengthVal is valid only if vType is VTYPE_GRIDLENGTH.

CornerRadiusVal

Passes an XRCornerRadius that describes the radius of the rectangle corners. CornerRadiusVal is valid only if vType is VTYPE_CORNER_RADIUS.

pObjectVal

Passes an IXRDependencyObject-derived object. pObjectVal is valid only if vType is VTYPE_OBJECT.

pPropertyBagVal

Passes an IXRPropertyBag object. pPropertyBagVal is valid only if vType is VTYPE_PROPERTYBAG.

pEnumerableVal

Passes an IXREnumerable object. pEnumerableVal is valid only if vType is VTYPE_ENUMERABLE.

const XRValue& operator=

Use to assign the value of this XRValue from another XRValue by using the "=" operator.

Remarks

XRValue is used to pass values of dependency properties or attached properties through methods in XAML for Windows Embedded. XRValue is also used to pass data source objects used in data binding.

Many methods in XAML 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 information 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 of vType indicates which member variable is valid when another API uses the XRValue object. For example, if vType is VTYPE_READONLY_STRING, then the XRValue object has a pReadOnlyStringVal member variable that contains a read-only Unicode string value.

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

When you set a new value by using XRValue::SetValue, the vType member is set automatically. XAML for Windows Embedded provides method overloads for each data type so you don't have to explicitly set the data type when you call SetValue. When you set a string by using XRValue::SetValue(const WCHAR*), the data type is const WCHAR. When you retrieve a string by using XRValue::GetValue(BSTR*), the data type is BSTR.

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 Value = 100;
  XRValue xrValue;
  xrValue.vType = VTYPE_FLOAT;
  xrValue.FloatVal = Value;

  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

See Also

Reference

Classes for Application Management
FreeXRValue
IXRValueCollection