Skip to content

Latest commit

 

History

History
75 lines (45 loc) · 5.32 KB

inktoolbarcustompen.md

File metadata and controls

75 lines (45 loc) · 5.32 KB
-api-id -api-type
T:Windows.UI.Xaml.Controls.InkToolbarCustomPen
winrt class

Windows.UI.Xaml.Controls.InkToolbarCustomPen

-description

Represents an InkToolbar pen for which the ink color palette and pen tip properties, such as shape, rotation, and size, are defined by the host app.

-remarks

To create an app-defined pen and corresponding button on the InkToolbar, use this class in conjunction with InkToolbarCustomPenButton.

-examples

Here's a definition of a custom calligraphic pen.

  1. In code-behind, we first create a custom pen class derived from InkToolbarCustomPen.

A custom pen class must override the CreateInkDrawingAttributesCore method and provide the InkDrawingAttributes for the custom configuration. In this example, we customize the following InkDrawingAttributes:

[!code-csharpCustomCalligraphicPen]

  1. In markup, we then bind our custom pen class using a {StaticResource} markup extension reference in the CustomPen attribute of the InkToolbarCustomPenButton element (alternatively, you can instantiate the custom pen and assign it to InkToolbarCustomPenButton.CustomPen in code).

You can use the built-in InkToolbarPenConfigurationControl (as shown here) or you can specify a custom InkToolbarPenConfigurationControl definition in the standard InkToolbar pen declaration.

Here's the declaration for the custom pen defined in the previous snippet.

[!code-xamlUI_AddCustomPen]

Here's the definition of CalligraphicPenIcon from the MainPage.xaml.cs file of this example.

[!code-csharpCustomCalligraphicPenMain]

-see-also

Pen and stylus interactions, Add an InkToolbar to a Universal Windows Platform (UWP) app, Get Started Tutorial: Support ink in your UWP app, Windows.UI.Xaml.Controls classes, InkToolbarPenButton, InkToolbarCustomPenButton, DependencyObject, Ink sample (JavaScript), Get Started Tutorial: Support ink in your UWP app, Coloring book sample, Family notes sample

-ignore