IVisualTreeService::SetProperty method (xamlom.h)

Sets a property value on a XAML element.

Syntax

HRESULT SetProperty(
  [in] InstanceHandle instanceHandle,
  [in] InstanceHandle value,
  [in] unsigned int   propertyIndex
);

Parameters

[in] instanceHandle

A handle to the element to set the property on.

[in] value

A handle to the value to set on the element property.

[in] propertyIndex

The index (in the XAML runtime cache) of the property to set.

Return value

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

The caller of SetProperty must know the index of the property to be set by first calling GetPropertyValuesChain and finding the property they want to set and retrieving its index. They must also have an InstanceHandle to a value, either by calling CreateInstance, or caching an earlier instance of some shared property, such as SolidColorBrush.

Requirements

Requirement Value
Minimum supported client Windows 10 [desktop apps only]
Minimum supported server Windows Server 2016 [desktop apps only]
Target Platform Windows
Header xamlom.h

See also

IVisualTreeService