Udostępnij za pośrednictwem


ContextItem Class

Represents a single piece of state in the designer.

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

Syntax

'Declaration
Public MustInherit Class ContextItem
'Usage
Dim instance As ContextItem
public abstract class ContextItem
public ref class ContextItem abstract
public abstract class ContextItem

Remarks

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 nulla null reference (Nothing in Visual Basic).

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.

Inheritance Hierarchy

System.Object
  Microsoft.Windows.Design.ContextItem
    Microsoft.Windows.Design.AssemblyReferences
    Microsoft.Windows.Design.Interaction.CurrentDesignerView
    Microsoft.Windows.Design.Interaction.FocusedTask
    Microsoft.Windows.Design.Interaction.Selection
    Microsoft.Windows.Design.Interaction.Tool

Thread Safety

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

See Also

Reference

ContextItem Members

Microsoft.Windows.Design Namespace

ContextItemManager

SubscribeContextCallback<ContextItemType>

ServiceManager

FeatureManager

Other Resources

Editing Context Architecture

Understanding WPF Designer Extensibility