IXRApplication::RegisterXamlObject (Compact 2013)

3/28/2014

This method registers a native Visual C++ object that XAML for Windows Embedded creates when the specified XAML tag is encountered during the parsing of an XAML file.

Syntax

virtual HRESULT STDMETHODCALLTYPE RegisterXamlObject(
  __in    REFIID                  iid,
  __in    LPCWCHAR                pXamlName,
  __in    LPCWCHAR                pNamespace,
  __in    PFN_CREATE_XAMLOBJECT   pfXamlObjectCreation,
  __in    REFIID                  coreIID,
  __out   UINT*                   pObjectId
) = 0;

Parameters

  • pXamlName
    [in] Pointer to a string that represents the name of the control as it will be referenced in XAML (as an element tag).

    If you are simultaneously developing a Microsoft Silverlight 3 version of your application for the desktop, use the same name as the managed version of the control in that application.

  • pNamespace
    [in] Pointer to a string that represents the common language runtime (CLR) namespace that the control belongs to.

    If you are simultaneously developing a Microsoft Silverlight 3 version of your application for the desktop, use the same name as the managed version of the namespace in that application.

  • pfXamlObjectCreation
    [in] PFN_CREATE_XAMLOBJECT callback function that specifies the function pointer that is used for creating a control. XAML for Windows Embedded calls this function when it encounters an element name in XAML that is not recognized.
  • coreIID
    [in] Reference to the IID of the object to create.

    To create an IID, you can prefix the name of the XAML element with the substring "IID_".

  • pObjectId
    [out] Pointer to a value that stores the identifier associated with the type of the object that you want to register.

Return Value

Returns an HRESULT that indicates success or failure.

Remarks

Before XAML for Windows Embedded parses an XAML file that contains a custom element tag, you must register the C++ class that will represent the XAML element. To do this, call RegisterXamlObject. After the C++ class is registered, XAML for Windows Embedded will be able to parse the source XAML and load it into the visual tree.

For more information about XAML namespaces, see Silverlight XAML Namespaces, and Mapping XAML Namespaces as Prefixes on MSDN.

Associate custom XAML elements with native C++ classes when you want to create a custom behavior, action, or event trigger that will correspond to a .NET Framework version that is available to the Microsoft Silverlight 3 version of your application. This is useful when simultaneously creating both versions of an application that use the same set of source XAML files.

The PFN_CREATE_XAMLOBJECT application-defined function returns the C++ class instance to XAML for Windows Embedded. The name of this function is passed to XAML for Windows Embedded during control registration by using RegisterXamlObject.

The type of the object specified in coreIID can be a dependency object, an effect, or any concrete type. XAML for Windows Embedded uses the type of that object to determine if the XAML tag is valid. For example, you could create a class called MyCustomClass that is designed to represent an XAML tag named <CustomTag>. If the base type of MyCustomClass is an IXRDependencyObject, then <CustomTag> can be defined in any location where a dependency object is expected, such as a child element of the <Resources> section.

You can use the pObjectId value later to register dependency properties or attached properties by calling IXRApplication::RegisterDependencyProperty or IXRApplication::RegisterAttachedProperty.

.NET Framework Equivalent

None.

Requirements

Header

XamlRuntime.h

sysgen

SYSGEN_XAML_RUNTIME

See Also

Reference

IXRApplication
IXRApplication::RegisterControl