次の方法で共有


IXRDependencyObject::SetAttachedProperty(const WCHAR*, const WCHAR*, XRGridLength*) (Compact 2013)

3/28/2014

This method sets the value of the specified attached property if the attached property has an XRGridLength type.

Syntax

virtual HRESULT STDMETHODCALLTYPE SetAttachedProperty(
    __in const WCHAR* pName,
    __in_opt const WCHAR* pNamespace,
    __in XRGridLength* pGridLength
) = 0;

Parameters

  • pName
    [in] Pointer to a string that contains the name of the attached property that you want to set for this object.
  • pNamespace
    [in, optional] Pointer to a string that contains the name of the namespace in which to look. Use this parameter to access an attached property of a custom control. If pNamespace is null, this method looks in the current default namespace.
  • pGridLength
    [in] Pointer to an XRGridLength structure that reflects the new value to set for the property that you specified in pName.

Return Value

Returns XR_E_INVALID_PROPERTY if this method was unable to locate the property requested. Otherwise, returns an HRESULT that indicates success or failure.

Remarks

You can use this method to set the value of attached properties in XAML for Windows Embedded, such as Canvas.Left, or to set the value of a custom attached property that you created and registered for a user-defined control. In this case, the attached property name consists of the owner class name for the attached property, a dot, and the attached property name ("ownerType.propertyName").

Example

The following lines of C++ code demonstrate the correct syntax for using this method to set the RowDefinition.Height attached property for an IXRGrid object.

Note

For readability, the following code example does not contain security checking or error handling. Do not use the following code in a production environment.

XRGridLength* size;
size.UnitValue = 20;
size.UnitType = XRGridUnitType.XRGridUnitType_Pixel;
pGrid->SetAttachedProperty(L"RowDefinition.Height", NULL, &size);

.NET Framework Equivalent

System.Windows.DependencyObject.SetValue

Requirements

Header

XamlRuntime.h

sysgen

SYSGEN_XAML_RUNTIME

See Also

Reference

IXRDependencyObject::SetAttachedProperty
IXRDependencyObject