Table of Contents

Class ShellProperty<T>

Namespace
Microsoft.WindowsAPICodePack.Shell.PropertySystem
Assembly
Microsoft.WindowsAPICodePack.Shell.dll

Defines a strongly-typed property object. All writable property objects must be of this type to be able to call the value setter.

public class ShellProperty<T> : IShellProperty

Type Parameters

T

The type of this property's value. Because a property value can be empty, only nullable types are allowed.

Inheritance
ShellProperty<T>
Implements
Inherited Members

Properties

AllowSetTruncatedValue

Gets or sets a value that determines if a value can be truncated. The default for this property is false.

public bool AllowSetTruncatedValue { get; set; }

Property Value

bool

Remarks

An ArgumentOutOfRangeException will be thrown if this property is not set to true, and a property value was set but later truncated.

CanonicalName

Gets the case-sensitive name of a property as it is known to the system, regardless of its localized name.

public string CanonicalName { get; }

Property Value

string

Description

Get the property description object.

public ShellPropertyDescription Description { get; }

Property Value

ShellPropertyDescription

IconReference

Gets the image reference path and icon index associated with a property value (Windows 7 only).

public IconReference IconReference { get; }

Property Value

IconReference

PropertyKey

Gets the property key identifying this property.

public PropertyKey PropertyKey { get; }

Property Value

PropertyKey

Value

Gets or sets the strongly-typed value of this property. The value of the property is cleared if the value is set to null.

public T Value { get; set; }

Property Value

T

Exceptions

COMException

If the property value cannot be retrieved or updated in the Property System

NotSupportedException

If the type of this property is not supported; e.g. writing a binary object.

ArgumentOutOfRangeException

Thrown if AllowSetTruncatedValue is false, and either a string value was truncated or a numeric value was rounded.

ValueAsObject

Gets the value for this property using the generic Object type. To obtain a specific type for this value, use the more type strong Property<T> class. Also, you can only set a value for this type using Property<T>

public object ValueAsObject { get; }

Property Value

object

ValueType

Gets the associated runtime type.

public Type ValueType { get; }

Property Value

Type

Methods

ClearValue()

Clears the value of the property.

public void ClearValue()

FormatForDisplay(PropertyDescriptionFormatOptions)

Returns a formatted, Unicode string representation of a property value.

public string FormatForDisplay(PropertyDescriptionFormatOptions format)

Parameters

format PropertyDescriptionFormatOptions

One or more of the PropertyDescriptionFormat flags that indicate the desired format.

Returns

string

The formatted value as a string, or null if this property cannot be formatted for display.

TryFormatForDisplay(PropertyDescriptionFormatOptions, out string)

Returns a formatted, Unicode string representation of a property value.

public bool TryFormatForDisplay(PropertyDescriptionFormatOptions format, out string formattedString)

Parameters

format PropertyDescriptionFormatOptions

One or more of the PropertyDescriptionFormat flags that indicate the desired format.

formattedString string

The formatted value as a string, or null if this property cannot be formatted for display.

Returns

bool

True if the method successfully locates the formatted string; otherwise False.