次の方法で共有


XRXamlSource (Compact 2013)

3/28/2014

This structure contains a pointer to a source of XAML markup.

Syntax

struct XRXamlSource {
  enum SourceType {
        XRS_STRING = 0,
        XRS_FILENAME,
        XRS_RESOURCE,
        XRS_STREAM
  };
  SourceType  Type;  
  union{
    const WCHAR *pStr; 
    IStream     *pStream;
    struct tagResouce {
      HMODULE      hMod;
      const WCHAR *pResType;
      const WCHAR *pResID;
    } Resource;
  } Value;

  Void SetFile(const WCHAR *psz) {
    Type = XRS_FILENAME; 
        Value.pStr = psz;
  }
  void SetString(const WCHAR *psz) {
    Type = XRS_STRING; 
        Value.pStr = psz;
  }
  void SetResource(HMODULE h, const WCHAR *pType, const WCHAR *pID) {
    Type = XRS_RESOURCE;
    Value.Resource.hMod = h;
    Value.Resource.pResType = pType;
    Value.Resource.pResID = pID;
  }
  void SetResource(HMODULE h,UINT ResID)
  {
      Type                    = XRS_RESOURCE;
      Value.Resource.hMod     = h;
      Value.Resource.pResType = SLWE_XAML;
      Value.Resource.pResID   = MAKEINTRESOURCE(ResID);
  }
  void SetStream(IStream* p) {
    Type = XRS_STREAM; 
        Value.pStream = p; 
  }
};

Members

  • Type
    Describes the source type of the XAML markup, which can be one of the following:

    • XRS_STRING
      String referenced in Value.pStr.
    • XRS_FILENAME
      File referenced in Value.pStr.
    • XRS_RESOURCE
      Resource with a resource ID referenced in Value.Resource.
    • XRS_STREAM
      Data stream referenced in Value.pStream.
  • Value.pStr
    Points to a null-terminated character string that contains either the XAML markup or the path of the file name that contains the XAML markup.
  • Value.pStream
    Points to an IStream interface that provides access to a stream object that contains XAML markup.
  • Value.Resource
    Identifies a resource that contains the XAML markup. Resource contains the following members:

    • hMod
      Handle to the application instance.
    • pResType
      Pointer to a string that describes the resource type, such as L"XAML".
    • pResID
      Pointer to a string that contains the resource ID.
  • SetFile
    Member function that sets the path of the source file that contains the XAML markup.

    The input parameter of this function is a pointer to a null-terminated string with the .xaml extension. You must specify the file name as a local path in local storage and not on a remote server or Web site.

    This function sets Type to XRS_FILENAME.

  • SetString
    Member function that sets the value of the source string that contains the XAML markup.

    You must set the input parameter of this method as a pointer to a null-terminated string.

    This function sets Type to XRS_STRING.

  • SetResource(HMODULE, const WCHAR *, const WCHAR *)
    Member function that sets the value of the resource that contains the XAML markup.

    This function has the following input parameters:

    • h
      Handle to the application instance.
    • pResType
      Pointer to a string that describes the resource type, such as L"XAML".
    • pID
      Pointer to a string that contains the ID of the resource. If you have an integer value, you can convert it to a resource type by using the MAKEINTRESOURCE macro.

    You must provide values for all three parameters. The function stores these values inside Value.Resource.

    This function sets Type to XRS_RESOURCE.

  • SetResource(HMODULE, UINT)
    Member function that sets the value of the resource that contains the XAML markup.

    This function has the following input parameters:

    • h
      Handle to the application instance.
    • ResID
      Pointer to an integer that contains the ID of the resource.

    You must provide values for both parameters. The function stores these values inside Value.Resource.

    This function sets Type to XRS_RESOURCE.

  • SetStream
    Member function that sets the pStream pointer to the stream source that contains the XAML markup.

    The input parameter is a pointer to an IStream interface that provides access to the stream object.

    This function sets Type to XRS_STREAM.

Remarks

You are responsible for managing the lifetime of the data that the structure members reference and for making sure that the data is available when the application uses the structure as a XAML source. This structure is a parameter in the IXRApplication::CreateHostFromXaml, IXRApplication::ParseXaml, and IXRApplication::ParseXamlWithExistingRoot methods.

Requirements

Header

XamlRuntime.h

sysgen

SYSGEN_XAML_RUNTIME

See Also

Reference

XAML for Windows Embedded Structures