StrokeCollection Class

Represents a collection of Stroke objects.

Namespace:  System.Windows.Ink
Assembly:  PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

'Declaration
<TypeConverterAttribute(GetType(StrokeCollectionConverter))> _
Public Class StrokeCollection _
	Inherits Collection(Of Stroke) _
	Implements INotifyPropertyChanged, INotifyCollectionChanged
<object>isfString</object>
<object StrokeCollection="isfString"/>

XAML Values

Term

Definition

isfString

A string that represents the stroke in base-64, encoded Ink Serialized Format (ISF).

The StrokeCollection type exposes the following members.

  NameDescription
Public methodStrokeCollectionInitializes a new instance of the StrokeCollection class.
Public methodStrokeCollection(IEnumerable(Of Stroke))Initializes a new instance of the StrokeCollection class that contains the specified strokes.
Public methodStrokeCollection(Stream)Initializes a StrokeCollection from the specified Stream of Ink Serialized Format (ISF).
Top

  NameDescription
Public propertyCountGets the number of elements actually contained in the Collection(Of T). (Inherited from Collection(Of T).)
Public propertyItemGets or sets the element at the specified index. (Inherited from Collection(Of T).)
Protected propertyItemsGets a IList(Of T) wrapper around the Collection(Of T). (Inherited from Collection(Of T).)
Top

  NameDescription
Public methodAdd(T)Adds an object to the end of the Collection(Of T). (Inherited from Collection(Of T).)
Public methodAdd(StrokeCollection)Adds the specified strokes to the StrokeCollection.
Public methodAddPropertyDataAdds a custom property to the StrokeCollection.
Public methodClearRemoves all elements from the Collection(Of T). (Inherited from Collection(Of T).)
Protected methodClearItemsInfrastructure. Clears all strokes from the StrokeCollection. (Overrides Collection(Of T).ClearItems.)
Public methodClip(IEnumerable(Of Point))Removes all strokes in the StrokeCollection that are outside the bounds of the specified Point array.
Public methodClip(Rect)Replaces all strokes that are clipped by the specified rectangle with new strokes that do not extend beyond the specified rectangle.
Public methodCloneCopies the StrokeCollection.
Public methodContainsDetermines whether an element is in the Collection(Of T). (Inherited from Collection(Of T).)
Public methodContainsPropertyDataReturns whether the specified custom property identifier is in the StrokeCollection.
Public methodCopyToCopies the entire Collection(Of T) to a compatible one-dimensional Array, starting at the specified index of the target array. (Inherited from Collection(Of T).)
Public methodDrawDraws the strokes in the StrokeCollection.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodErase(IEnumerable(Of Point))Removes the ink that is within the bounds of the specified area.
Public methodErase(Rect)Replaces all strokes that are clipped by the specified rectangle with new strokes that do not enter the bounds of the specified rectangle.
Public methodErase(IEnumerable(Of Point), StylusShape)Replaces all strokes that are clipped by the region created by the specified StylusShape along the specified path with new Strokes that are not clipped by the region.
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetBoundsReturns the bounds of the strokes in the collection.
Public methodGetEnumeratorReturns an enumerator that iterates through the Collection(Of T). (Inherited from Collection(Of T).)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetIncrementalLassoHitTesterCreates an IncrementalLassoHitTester that hit tests the StrokeCollection with a lasso (freehand) path.
Public methodGetIncrementalStrokeHitTesterCreates an IncrementalStrokeHitTester that hit tests the StrokeCollection with an erasing path.
Public methodGetPropertyDataReturns the value of the custom property associated with the specified Guid.
Public methodGetPropertyDataIdsReturns the GUIDs of any custom properties associated with the StrokeCollection.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodHitTest(Point)Returns a collection of strokes that intersect the specified point.
Public methodHitTest(IEnumerable(Of Point), Int32)Returns a collection of strokes that have at least the specified percentage of length within the specified area.
Public methodHitTest(IEnumerable(Of Point), StylusShape)Returns a collection of strokes that intersect with the specified path.
Public methodHitTest(Point, Double)Returns a collection of strokes that intersect the specified area.
Public methodHitTest(Rect, Int32)Returns a collection of strokes that have at least the specified percentage of length within the specified rectangle.
Public methodIndexOfReturns the index of the specified Stroke in the StrokeCollection.
Public methodInsertInserts an element into the Collection(Of T) at the specified index. (Inherited from Collection(Of T).)
Protected methodInsertItemInfrastructure. Inserts a stroke into the StrokeCollection at the specified index. (Overrides Collection(Of T).InsertItem(Int32, T).)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodOnPropertyChangedOccurs when any StrokeCollection property changes.
Protected methodOnPropertyDataChangedRaises the PropertyDataChanged event.
Protected methodOnStrokesChangedRaises the StrokesChanged event.
Public methodRemove(T)Removes the first occurrence of a specific object from the Collection(Of T). (Inherited from Collection(Of T).)
Public methodRemove(StrokeCollection)Removes the specified strokes from the collection.
Public methodRemoveAtRemoves the element at the specified index of the Collection(Of T). (Inherited from Collection(Of T).)
Protected methodRemoveItemInfrastructure. Removes the stroke at the specified index from the StrokeCollection. (Overrides Collection(Of T).RemoveItem(Int32).)
Public methodRemovePropertyDataRemoves the custom property associated with the specified Guid.
Public methodReplace(Stroke, StrokeCollection)Replaces the specified Stroke with the specified StrokeCollection.
Public methodReplace(StrokeCollection, StrokeCollection)Replaces the specified StrokeCollection with a new StrokeCollection.
Public methodSave(Stream)Saves the StrokeCollection to the specified Stream.
Public methodSave(Stream, Boolean)Saves the StrokeCollection to the specified Stream and compresses it, when specified.
Protected methodSetItemInfrastructure. Replaces the stroke at the specified index. (Overrides Collection(Of T).SetItem(Int32, T).)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodTransformModifies each of the StylusPoints and optionally the StylusTipTransform for each stroke in the StrokeCollection according to the specified Matrix.
Top

  NameDescription
Public eventPropertyDataChangedOccurs when custom property is added or removed from the StrokeCollection.
Public eventStrokesChangedOccurs when a Stroke in the collection changes.
Top

  NameDescription
Public fieldStatic memberInkSerializedFormatRepresents the native persistence format for ink data.
Top

  NameDescription
Explicit interface implemetationPrivate methodICollection.CopyToCopies the elements of the ICollection to an Array, starting at a particular Array index. (Inherited from Collection(Of T).)
Explicit interface implemetationPrivate propertyICollection(Of T).IsReadOnlyGets a value indicating whether the ICollection(Of T) is read-only. (Inherited from Collection(Of T).)
Explicit interface implemetationPrivate propertyICollection.IsSynchronizedGets a value indicating whether access to the ICollection is synchronized (thread safe). (Inherited from Collection(Of T).)
Explicit interface implemetationPrivate propertyICollection.SyncRootGets an object that can be used to synchronize access to the ICollection. (Inherited from Collection(Of T).)
Explicit interface implemetationPrivate methodIEnumerable.GetEnumeratorReturns an enumerator that iterates through a collection. (Inherited from Collection(Of T).)
Explicit interface implemetationPrivate methodIList.AddAdds an item to the IList. (Inherited from Collection(Of T).)
Explicit interface implemetationPrivate methodIList.ContainsDetermines whether the IList contains a specific value. (Inherited from Collection(Of T).)
Explicit interface implemetationPrivate methodIList.IndexOfDetermines the index of a specific item in the IList. (Inherited from Collection(Of T).)
Explicit interface implemetationPrivate methodIList.InsertInserts an item into the IList at the specified index. (Inherited from Collection(Of T).)
Explicit interface implemetationPrivate propertyIList.IsFixedSizeGets a value indicating whether the IList has a fixed size. (Inherited from Collection(Of T).)
Explicit interface implemetationPrivate propertyIList.IsReadOnlyGets a value indicating whether the IList is read-only. (Inherited from Collection(Of T).)
Explicit interface implemetationPrivate propertyIList.ItemGets or sets the element at the specified index. (Inherited from Collection(Of T).)
Explicit interface implemetationPrivate methodIList.RemoveRemoves the first occurrence of a specific object from the IList. (Inherited from Collection(Of T).)
Explicit interface implemetationPrivate eventINotifyCollectionChanged.CollectionChangedInfrastructure. Occurs when the StrokeCollection changes.
Explicit interface implemetationPrivate eventINotifyPropertyChanged.PropertyChangedInfrastructure. Occurs when the value of any StrokeCollection property has changed.
Top

The StrokeCollection enables you to perform functions such as hit testing, clipping, and erasing strokes. The InkCanvas control performs many of these functions, but if you need more control than the InkCanvas provides, the StrokeCollection offers more options.

The following table lists where to learn about managing digital ink on a custom control.

To do this…

See this article

Create a control that collects digital ink

Creating an Ink Input Control

Create a control that enables the user to select ink

How to: Select Ink from a Custom Control

Create a control that enables the user to point-erase ink

How to: Erase Ink on a Custom Control

The following example demonstrates how to copy the ink in one InkCanvas onto another InkCanvas. This example assumes:

  • There are two InkCanvas objects called inkCanvas1 and inkCanvas2.

  • The Click event has been connected to the event handler.

' Copy the strokes from one InkCanvas to another InkCanvas. 
Private Sub CopyStrokes_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)

    Dim strokes As StrokeCollection = inkCanvas1.Strokes.Clone()
    inkCanvas2.Strokes.Clear()
    inkCanvas2.Strokes.Add(strokes)

End Sub

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft