IXRDependencyObject::SetAttachedProperty(const WCHAR*, int) (Windows Embedded CE 6.0)

1/6/2010

This method sets the value of the specified attached property.

Use this method if the specified attached property has a 32-bit integer type, or if it has an enumerated type that is also represented by an integer.

Syntax

virtual HRESULT STDMETHODCALLTYPE SetAttachedProperty(
    const WCHAR *pDP,
    int Value
) = 0;

Parameters

  • pDP
    [in] Pointer to a string that contains the name of the attached property that you want to set for this object.
  • Value
    [in] Pointer to an integer value that reflects the new value to set for the property that you specified in pDP.

Return Value

Returns an HRESULT that indicates success or failure.

Returns XR_E_INVALID_PROPERTY if this method was unable to locate the property requested.

Remarks

Attached properties are a concept that is part of the XAML language. You can set an attached property on objects or XAML elements, even if that property is not conventionally defined in the properties list that belongs to the setting object. For attached properties such as Canvas.Top, the object.property notation does not work because the two "dots" in the syntax create ambiguity. Instead, you set attached properties in Silverlight by using a (C++) string that defines the full dotted name of the attached property (for example, L"Canvas.Top"). In the pDP parameter, the "." (dot) is considered part of the property name/identifier.

You can use this method to set the value of attached properties in Silverlight for Windows Embedded, such as Canvas.Left. 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").

You can call this method to set the value of an attached property in Silverlight, or to set the value of a custom attached property that you created and registered for a user-defined control.

Example

The following lines of C++ code demonstrate the correct syntax for using this method to set the ScrollViewer.HorizontalScrollBarVisibility attached property for the inheriting IXRUIElement object by casting it to its integer value:

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.

XRScrollBarVisibility Value = XRScrollBarVisibility_Visible;
myElement->SetAttachedProperty(L"ScrollViewer.HorizontalScrollBarVisibility" , (int)Value);

Silverlight Equivalent

SetValue

Requirements

Header XamlRuntime.h
sysgen SYSGEN_XAML_RUNTIME
Windows Embedded CE Windows Embedded CE 6.0 R3

See Also

Reference

IXRDependencyObject::SetAttachedProperty
IXRDependencyObject