This documentation is archived and is not being maintained.

ContextItem Class

Represents a single piece of state in the designer.

Namespace:  Microsoft.Windows.Design
Assembly:  Microsoft.Windows.Design (in Microsoft.Windows.Design.dll)

public abstract class ContextItem

Context items are immutable objects that contain state. Some context items also define methods that can perform operations on the state they contain. ContextItem is the base class from which all context items must derive.

A context item may come and go in an editing context. Context items are transient, but they always have a value. Even if a particular context item is not in the context, a default value is always provided. Therefore, the context never returns null.

Unlike a service, the value of a context item can change at any moment. This means that you should not cache context items. Code that uses the context can subscribe to a SubscribeContextCallback<ContextItemType> that is raised when a particular type of context item changes.

A class derived from ContextItem must define an empty constructor. This empty constructor version of a context item represents its default value. This default value is the value returned from GetValue if the ContextItemManager does not contain a context item of the requested type.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.