Share via


PFN_TYPE_CONVERTER (Compact 2013)

3/28/2014

This callback function is defined by the application. When an application calls IXRCustomUserControlBase::SetPropertyValueXAML for Windows Embedded calls this function in case a XAML type must be converted into a C++ type. The PFN_TYPE_CONVERTER type defines a pointer to this callback function.

Syntax

typedef HRESULT (CALLBACK* PFN_TYPE_CONVERTER)(
    XRValue *pValIn, 
    XRValue *pValOut
);

Parameters

  • pValIn
    [in] Points to an XRValue object that indicates the type value, in case this value must be converted from a XAML type to another type in C++.

    When XAML for Windows Embedded calls this function in the parsing phase, pValIn will always be a string, but when XAML for Windows Embedded calls it from SetPropertyValue, pValIn can be any VALUE_TYPE enumerated type that a custom function passed to SetPropertyValue.

  • pValOut
    [out] Points to an XRValue object that contains the correct type and value for a specific property that the source XAML defined.

    The type indicated in XRValue must specify one of the types available in the VALUE_TYPE enumeration.

    String values must be of type VTYPE_BSTR and be allocated with SysAllocString.

Return Value

Returns an HRESULT that indicates success or failure.

Remarks

This function pointer specifies a type converter for a dependency property and is a member of the XRDependencyPropertyMetaData structure. When you specify this function pointer in XRDependencyPropertyMetaData, XAML for Windows Embedded calls your custom function to convert the property to the correct object type and value. You must implement the custom function with a function signature that matches the function signature shown in the syntax section.

Example

The following code example shows an example implementation of this callback function.

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>

static HRESULT ConvertNameTypeConverter(XRValue *pValIn, XRValue *pValOut)
    {
        WCHAR NewString[MAX_PATH] = L"";
        StringCchPrintf(NewString, MAX_PATH, L"New%s", pValIn->pReadOnlyStringVal);

        pValOut->vType = VTYPE_BSTR;
        pValOut->bstrStringVal = SysAllocString(NewString);

        return S_OK;
    };      

.NET Framework Equivalent

None.

Requirements

Header

XamlRuntime.h

sysgen

SYSGEN_XAML_RUNTIME

See Also

Reference

XAML for Windows Embedded Functions