AddPropertyData Method

Stroke.AddPropertyData Method (Guid, Object)

 

Adds a custom property to the Stroke object.

Namespace:   System.Windows.Ink
Assembly:  PresentationCore (in PresentationCore.dll)

public void AddPropertyData(
	Guid propertyDataId,
	object propertyData
)

Parameters

propertyDataId
Type: System.Guid

The unique identifier for the property.

propertyData
Type: System.Object

The value of the custom property. propertyData must be of type Char, Byte,Int16,,UInt16, Int32, UInt32, Int64, UInt64, Single, Double, DateTime, Boolean, String, Decimal or an array of these data types, except String, which is not allowed.

Exception Condition
ArgumentException

The propertyData argument is not one of the allowed data types listed in the Parameters section.

This method is useful if you need to store extra information in the Stroke.

The following example demonstrates how to add a custom property to a Stroke object.

// Create a guid for the date/timestamp.
Guid dtGuid = new Guid("03457307-3475-3450-3035-640435034540");

DateTime now = DateTime.Now;

// Check whether the property is already saved
if (thisStroke.ContainsPropertyData(dtGuid))
{
    // Check whether the existing property matches the current date/timestamp
    DateTime oldDT = (DateTime)thisStroke.GetPropertyData(dtGuid);

    if (oldDT != now)
    {
        // Update the current date and time
        thisStroke.AddPropertyData(dtGuid, now);
    }
}

.NET Framework
Available since 3.0
Return to top
Show:
© 2016 Microsoft