Share via


ContextItemCollection Class

The ContextItemCollection class maintains a set of context items. A context item represents a piece of transient state in a designer. ContextItems must define an empty constructor. This empty constructor version of a context item represents its default value, and will be the value returned from GetItem if the context item manager does not contain a context item of the requested type. The ContextItemCollection supports context layers. A context layer is a separation in the set of context items and is useful when providing modal functions. For example, when switching modes in the designer to show the tab order layout it may be desirable to disable adding items from the toolbox and change the user mouse and keyboard gestures to focus on setting the tab order. Rather than grabbing and storing context items before replacing them with new values, a developer can simply call CreateLayer. Once the layer is created, all subsequent context changes go to that layer. When the developer is done with the layer, as would be the case when a user switches out of tab order mode, she simply calls Remove on the layer. This removes all context items that were added to the layer and restores the context to its previous set of values before the layer was created.

Inheritance Hierarchy

System..::..Object
  Microsoft.Data.Tools.Design.Core.Context..::..ContextItemCollection

Namespace:  Microsoft.Data.Tools.Design.Core.Context
Assembly:  Microsoft.Data.Tools.Design.Core (in Microsoft.Data.Tools.Design.Core.dll)

Syntax

'Declaration
Public MustInherit Class ContextItemCollection _
    Implements IEnumerable(Of ContextItem), IEnumerable
'Usage
Dim instance As ContextItemCollection
public abstract class ContextItemCollection : IEnumerable<ContextItem>, 
    IEnumerable
public ref class ContextItemCollection abstract : IEnumerable<ContextItem^>, 
    IEnumerable
[<AbstractClassAttribute>]
type ContextItemCollection =  
    class
        interface IEnumerable<ContextItem>
        interface IEnumerable
    end
public abstract class ContextItemCollection implements IEnumerable<ContextItem>, IEnumerable

The ContextItemCollection type exposes the following members.

Constructors

  Name Description
Protected method ContextItemCollection Creates a new ContextItemCollection object.

Top

Methods

  Name Description
Public method Contains(Type) Returns true if the item collection contains an item of the given type.
Public method Contains< (Of < <' (TItemType> ) > > )() () () () Returns true if the item manager contains an item of the given type.
Public method CreateLayer Creates a new editing context layer. Editing context layers can be used to create editing modes. For example, you may create a layer before starting a drag operation on the designer. Any new context items you add to the layer hide context items underneath it. When the layer is removed, all context items under the layer are re-surfaced. This allows you to create a layer and set overrides for context items during operations such as drag and drop.
Public method Equals (Inherited from Object.)
Protected method Finalize (Inherited from Object.)
Public method GetEnumerator Enumerates the context items in the editing context. This enumeration includes prior layers unless the enumerator hits an isolated layer. Enumeration is typically not useful in most scenarios but it is provided so that developers can search in the context and learn what is placed in it.
Public method GetHashCode (Inherited from Object.)
Protected methodStatic member GetTarget This is a helper method that returns the target object for a delegate. If the delegate was created to proxy a generic delegate, this will correctly return the original object, not the proxy.
Public method GetType (Inherited from Object.)
Public method GetValue(Type) Returns an instance of the requested item type. If there is no context item with the given type, an empty item will be created.
Public method GetValue< (Of < <' (TItemType> ) > > )() () () () Returns an instance of the requested item type. If there is no context item with the given type, an empty item will be created.
Protected method MemberwiseClone (Inherited from Object.)
Protected methodStatic member NotifyItemChanged This is a helper method that invokes the protected OnItemChanged method on ContextItem.
Protected methodStatic member RemoveCallback This is a helper method that performs a Delegate.Remove, but knows how to unwrap delegates that are proxies to generic callbacks. Use this in your Unsubscribe implementations.
Public method SetValue This sets a context item to the given value. It is illegal to pass null here. If you want to set a context item to its empty value create an instance of the item using a default constructor.
Public method Subscribe(Type, SubscribeContextCallback) Adds an event callback that will be invoked with a context item of the given item type changes.
Public method Subscribe< (Of < <' (TContextItemType> ) > > )(SubscribeContextCallback< (Of < <' (TContextItemType> ) > > )) Adds an event callback that will be invoked with a context item of the given item type changes.
Public method ToString (Inherited from Object.)
Public method Unsubscribe(Type, SubscribeContextCallback) Removes a subscription.
Public method Unsubscribe< (Of < <' (TContextItemType> ) > > )(SubscribeContextCallback< (Of < <' (TContextItemType> ) > > )) Removes a subscription.

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate method IEnumerable..::..GetEnumerator Implementation of default IEnumerable.

Top

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

Microsoft.Data.Tools.Design.Core.Context Namespace