* Reset branch for WPF changes * Convert BMP to PNG; fix link-out-of-scope err * Add snippets for WPF... 6794 files!!!! * Add missing snippets * update file updated between migration * Fix paths to include * update breadcrumb and toc * fix index links * fix index links * fix index links * fix markdown
2.7 KiB
title, ms.date, helpviewer_keywords, ms.assetid
| title | ms.date | helpviewer_keywords | ms.assetid | ||
|---|---|---|---|---|---|
| How to: Add Custom Data to Ink Data | 03/30/2017 |
|
f02aac6f-3436-4f7c-b6ea-0452cba5332c |
How to: Add Custom Data to Ink Data
You can add custom data to ink that will be saved when the ink is saved as ink serialized format (ISF). You can save the custom data to the xref:System.Windows.Ink.DrawingAttributes, the xref:System.Windows.Ink.StrokeCollection, or the xref:System.Windows.Ink.Stroke. Being able to save custom data on three objects gives you the ability to decide the best place to save the data. All three classes use similar methods to store and access custom data.
Only the following types can be saved as custom data:
Example
The following example demonstrates how to add and retrieve custom data from a xref:System.Windows.Ink.StrokeCollection.
[!code-csharpHowToAddCustomDataToInk#1]
The following example creates an application that displays an xref:System.Windows.Controls.InkCanvas and two buttons. The button, switchAuthor, enables two pens to be used by two different authors. The button changePenColors changes the color of each stroke on the xref:System.Windows.Controls.InkCanvas according to the author. The application defines two xref:System.Windows.Ink.DrawingAttributes objects and adds a custom property to each one that indicates which author drew the xref:System.Windows.Ink.Stroke. When the user clicks changePenColors, the application changes the appearance of the stroke according to the value of the custom property.
[!code-xamlHowToAddCustomDataToInk#2]
[!code-csharpHowToAddCustomDataToInk#3]